Reputation: 49
I have a object array=[1,2,3,4,5] with html.What is the proper way to update inside the ng-repeat conditioned by values of array ?. I will put an example :
<ul>
<li ng-repeat="nr in array">
<p> {{ nr}} </p>
<ul>
<li ng-repeat="stuff in stuffs(nr)"> {{stuff}} </li>
</ul>
</li>
</ul>
i've tried to make a scope function in controller:
scope.stuffs = function(ret){
......
return arrayConditionedbyNr;
}
but is throwing an error :
Uncaught Error: 10 $digest() iterations reached. Aborting! Watchers fired in the last 5 iterations: ...
can you please guide me in the right direction ?
Upvotes: 0
Views: 103
Reputation: 49
this is my html :
<h2> Last Updates </h2>
<ul>
<li ng-repeat="cat in eachCateg">
<h3> {{cat}} </h3>
<ul>
<li ng-repeat="game in eachGame(cat)">
<p>{{game.id}}</p>
</li> -->
</ul>
</li>
</ul>
this is my controller :
applicaton.controller('homeController', ['$scope','$http','$stateParams','$q',function(scope,http,stateParams,q){
// server request with http angular.js, taking category list from JSON for scope.eachCateg
var getCategories = http.get('data/menu/menu.json')
.success(function(result){
scope.eachCateg = result.categories;
});
scope.eachGame = function(categ) {
var httpRequest = http.get('data/games/'+ angular.lowercase(categ)+'/urlThumb.json')
.success(function(result){
return result;
})
return q.all([httpRequest]).then(function(result){
return result[0].data;
})
}
}]);
so this is how i try to update the list and i got that error. It seems to be that it returns me a promise not actual data. How i can make to send me in return the data wanted ?
Upvotes: 0
Reputation: 463
perhaps I missed your problem.. but this following plunker works for me http://plnkr.co/edit/iCepagIKA1OFDjBnB35I?p=preview
perhaps you needed <div ng-repeat="test in getArr(item.id) track by $index">
Upvotes: 0