Posts

Showing posts with the label ngRepeat

Post ngRepeat Code

all those questions, How to run function after ngRepeat is done Calling a function when ng-repeat has finished ng-repeat finish event all the answers in stackoverflow goes around <ul> <li ng-repeat = "item in items" ng-init = "$last ? doSomething() : angular.noop()" > {{item}} </li> </ul> which are nice and are a real solution, while each answer eventually give the same solution a bit more generic. one blog puts it quite better, while also enabling to choose the digest cycle stage, with the exception that you better use $parse instead of $eval: http://www.bennadel.com/blog/2592-hooking-into-the-complete-event-of-an-ngrepeat-loop-in-angularjs.htm but in the end we usually just do some simple JS or JQ code or plugin, and i think that the real solution here is a simple setTimeout since the setTimeout function gets pushed to the end of the queue of the browser, its always right after everything is done in angular, usu...

ng-repeat working with JSON objects

today i had quite  a fight vs ng-repeat while trying to loop over some json objects i'll just sum it cause in the end its quite easy. you can try it yourself, I prepared a little jsbon for it: http://jsbin.com/roranijaba/1/edit?html,output 1 - simple array this is just for the sake of the example, when your object in an array, ngRepeat looks like this < div ng-init ="friends = ['Jhonny','Jessy','Marky']">   < ul >     < li ng-repeat ="friend in friends">       {{ friend }} .     </ li >   </ ul > </ div > 2 - array of json objects this is where you can use the power of parameter with ngRepeat < div ng-init ="friends = [{name:'John', age:25, gender:'boy'},        {name:'Jessie', age:30, gender:'girl'},        {name:'Patrick', age:40, gender:'boy'}]">   ...