At http://www.binpress.com/tutorial/speeding-up-angular-js-with-simple-optimizations/135
it is written that for directives it is better to use interpolate than ng-repeat:
The ng-repeat directive is most likely the worst offender for performance concerns, which means it can easily be abused. An ng-repeat likely deals with Arrays of $scope Objects and this hammers the $digest cycle’s performance.
For example, instead of rendering a global navigation using ng-repeat, we could create our own navigation using the $interpolate provider to render our template against an Object and convert it into DOM nodes.
When using angular 1.3 we could use ng-repeat with one time bindings to achieve the same result.
Is it still better to use $interpolate for this purpose?
I'd recommend bindonce for this if you're on <1.3, just add bindonce
next to your ng-repeat
and change your ng-*
directives to bo-*
in the repeating part. It basically does the same thing as 1.3's one time bindings.
If by your quetion you meant should you use $interpolate
instead of one time binding in 1.3, I'd say go with ng-repeat
with one time binding since there aren't any watchers to slow you down and it's a lot more readable. Even though ng-repeat
still creates the child scopes, the performance difference is negligible if you're not doing anything in those scopes.
From experience you'll hit performance issues in your browser in rendering so many elements before $digest
becomes an issue if you're not checking watchers, even with a lot of child scopes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With