ng-repeat finish event

I want to call some jQuery function targeting div with table. That table is populated with ng-repeat. When I call it on $(document).ready() I have no result. Also $scope.$on(‘$viewContentLoaded’, myFunc); doesn’t help. Is there any way to execute function right after ng-repeat population completes? I’ve read an advice about using custom directive, but I have … Read more

Access index of the parent ng-repeat from child ng-repeat

I want to use the index of the parent list (foos) as an argument to a function call in the child list (foos.bars). I found a post where someone recommends using $parent.$index, but $index is not a property of $parent. How can I access the index of the parent ng-repeat? <div ng-repeat=”f in foos”> <div> … Read more

angular ng-repeat in reverse

How can i get a reversed array in angular? i’m trying to use orderBy filter, but it needs a predicate(e.g. ‘name’) to sort: <tr ng-repeat=”friend in friends | orderBy:’name’:true”> <td>{{friend.name}}</td> <td>{{friend.phone}}</td> <td>{{friend.age}}</td> <tr> Is there a way to reverse original array, without sorting. like that: <tr ng-repeat=”friend in friends | orderBy:”:true”> <td>{{friend.name}}</td> <td>{{friend.phone}}</td> <td>{{friend.age}}</td> <tr> … Read more

AngularJS For Loop with Numbers & Ranges

Angular does provide some support for a for loop using numbers within its HTML directives: <div data-ng-repeat=”i in [1,2,3,4,5]”> do something </div> But if your scope variable includes a range that has a dynamic number then you will need to create an empty array each time. In the controller var range = []; for(var i=0;i<total;i++) … Read more

How to use ng-repeat for dictionaries in AngularJs?

I know that we can easily use ng-repeat for json objects or arrays like: <div ng-repeat=”user in users”></div> but how can we use the ng-repeat for dictionaries, for example: var users = null; users[“182982”] = “{…json-object…}”; users[“198784”] = “{…json-object…}”; users[“119827”] = “{…json-object…}”; I want to use that with users dictionary: <div ng-repeat=”user in users”></div> Is … Read more

AngularJS ng-repeat handle empty list case

I thought this would be a very common thing, but I couldn’t find how to handle it in AngularJS. Let’s say I have a list of events and want to output them with AngularJS, then that’s pretty easy: <ul> <li ng-repeat=”event in events”>{{event.title}}</li> </ul> But how do I handle the case when the list is … Read more

orderBy multiple fields in Angular

How to sort by using multiple fields at same time in angular? fist by group and then by sub-group for Example $scope.divisions = [{‘group’:1,’sub’:1}, {‘group’:2,’sub’:10}, {‘group’:1,’sub’:2},{‘group’:1,’sub’:20},{‘group’:2,’sub’:1}, {‘group’:2,’sub’:11}]; I wanted to display this as group : Sub-group 1 – 1 1 – 2 1 – 20 2 – 1 2 – 10 2 – 11 <select … Read more

Way to ng-repeat defined number of times instead of repeating over array?

Is there a way to ng-repeat a defined number of times instead of always having to iterate over an array? For example, below I want the list item to show up 5 times assuming $scope.number equal to 5 in addition incrementing the number so each list item increments like 1, 2, 3, 4, 5 Desired … Read more