1. Define Factory.js files
var appFactorys = angular.module('starter.factorys', [])
appFactorys.factory('HouseFactory', function () {
var houseList = [
{ID: 0, Title: 'sale of complete and fine decoration of Beierhuan district', price: '88.0', Description: '120 square meters of room 1, room 2', IMG: 'img / Ben. PNG'},
{ID: 1, Title: 'urgent sale of complete and fine decoration of East 2nd Ring Road community', price: '88.0', Description: '120 square meters of room 1, room 2', IMG: 'img / max.png'},
{ID: 2, Title: 'the south 2nd Ring Road community is fully equipped with fine decoration', price: '87.0', Description: 'room 1, room 2, 120 square meters', IMG:' img / Adam. JPG '},
{ID: 3, Title: 'urgent sale of complete and fine decoration of West 2nd Ring Road community', price: '86.0', Description: '120 square meters of room 1, room 2', IMG: 'img / Perry. PNG'},
{ID: 4, Title: 'sale of complete and fine decoration of Beierhuan district', price: '85.0', Description: '120 square meters of room 1, room 2', IMG: 'img / Mike. PNG'}
];
Return {
all: function () {
return houseList;
}
}
};
2. Referencing factory.js file in App.js file
Angular.module (' starter ', [' Ionic ', ' Ngcordova ', ' starter.directives ', ' Starter.factorys ', ' starter.services ', '] Starter.customcontrollers '])
3. Call factory in controller
Appcontrollers.controller (' Housectrl ', function ($scope, $timeout, $ionicModal, $ionicActionSheet, $http, $ Cordovatoast, $ionicLoading, housefactory) {
//$scope. houselist = [/
/ {id:0, title: ' Urgent sale of the North two-ring community supporting complete fine decoration ', PR Ice: ' 88.0 ', describe: ' 2 Room 1 Hall 120 square meters ', img: ' Img/ben.png '},
// {id:1, title: ' Urgent sale East two ring community supporting complete fine decoration ', Price: ' 88.0 ', D Escribe: ' 2 Room 1 Hall 120 square meters ', img: ' Img/max.png '},
// {id:2, title: ' Urgent sales South two ring community complete finishing ', Price: ' 87.0 ', describe: ' 2 Room 1 Hall 120 square meters ', img: ' img/adam.jpg '},
// {id:3, title: ' Urgent sale West two ring plot complete complete fine decoration ', Price: ' 86.0 ', describe: ' 2 Room 1 Hall 120 square meters ', IMG: ' Img/perry.png '},
// {id:4, title: ' Urgent sale of the North two-ring community complete matching fine decoration ', Price: ' 85.0 ', describe: ' 2 Room 1 Hall 120 square meters ', img: ' Img/mike. PNG '}
//];
/* Call Factory.js data
/$scope. Houselist = Housefactory.all ();
})
4, HTML page calls
<ion-list>
<ion-item class="item item-thumbnail-left" ng-repeat="item in houseList" href="#/housedetail/{{item.id}}" style="padding--bottom:2px">
<img ng-src="{{item.img}}">
<h2>{{item.title}}</h2>
<dd class="assertive cus-price">{{item.price}} ten thousand yuan</dd>
<dd class="u-f-h4">{{item.describe}}</dd>
</ion-item>
</ion-list>