即时通讯工作与AnuglarJS 1.4.8。我想用ng-repeat给出数据。
我有以下问题,我没有更多的想法来解决它。我尝试了AnuglarJS的解决方案,但我没有工作。
有人可以帮助我。
Error: [$rootScope:infdig] 10 $digest() iterations reached. Aborting!
Watchers fired in the last 5 iterations: []
http://errors.angularjs.org/1.4.8/ $rootScope/infdig?p0=10&p1=%5B%5D
服务:
.service('database', function ($http) {
self = this;
this.url = 'http://localhost:3001';
this.getPersons = function(cb){
return $http({
method: 'GET',
url: self.url + '/loadperson'
}).success(function (data) {
cb(data);
});
};
});
控制器:
angular.module('myApp')
.controller('personCtrl', function ($scope, database) {
$scope.people = function(){
return{
getAll: function() {
database.getPersons(function (data) {
return data;
// should return a Object(id, name)
});
}
}
};
HTML:
<div ng-repeat="people in people().getAll()">
<p>{{people.name}}</p>
</div>
我怎么能存储对象? – kicki
将它存储在'$ scope'中。并始终返回相同的实例。 – elTomato