Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AngularJS - Is it clean to use $timeout to execute function after ng-repeat

I'm using ngRepeat directive to render a big data list and I'm using $timeout to execute a function after the ng-repeat if finished. It works well, but is it a proper way ?

I mean will it work for all the cases ?

like image 462
Sn0opr Avatar asked Apr 05 '26 19:04

Sn0opr


1 Answers

You can try $last ($last = true if the repeated element is last in the iterator).

<div ng-repeat="item in data">
    <span ng-if="$last === true" ng-init="doSomething()"></span>
</div>

Example: http://jsfiddle.net/by3qk8w5/2/

like image 57
user2700840 Avatar answered Apr 08 '26 14:04

user2700840



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!