Hi Sander, Thao, I had to overcome this issue today. My case was the fact that I was building a dialog that I need to position in the middle of the screen. The dialog's content is ng-repeat directive that has dynamic size. I need to call my function *centerDialog* once everything is rendered and I need to know its final height to calculate the new offset of the dialog.
So, this ideally needs to happen *after* the last element is rendered. The trick is to use *$timeout **or** $evalAsync *. The difference is well explained over here: http://stackoverflow.com/questions/17301572/angularjs-evalasync-vs-timeout My code goes: > > *.directive('toursDialogList', function($timeout){* > > * return {* > > * restrict: 'A',* > > * replace: false,* > > * template: '<div class="entry" >> ng-click="startTour(tourObject)"></div>',* > > * link: function(scope, element) {* > > * if (scope.$last) {* > > >> * $timeout(scope.centerDialog);* > > * }* > > * }* > > * };* > > *})* > > I hope that helps. - Patryk On Tuesday, March 11, 2014 5:45:54 AM UTC, Sander Elias wrote: > > Hi Thao, > > It is possible to do, and it can even be done in the template. When the > last data-item is rendered item.$last === true. This is of course > documented <http://docs.angularjs.org/api/ng/directive/ngRepeat>. > However, usually this is not a good idea, unless you need to something > visual with the last item. > What is it you want to get done? > > Regards > Sander > -- You received this message because you are subscribed to the Google Groups "AngularJS" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/angular. For more options, visit https://groups.google.com/d/optout.
