Skip to content Skip to sidebar Skip to footer

Ng-repeat Showing Irregular Behavior With One Time Binding

I am having a ng-repeat directive that is running on the array on object. I am facing a specific scenario in which, When I Bind my object properties with one time binding they are

Solution 1:

From the Docs:

Avoid using track by $index when the repeated template contains one-time bindings. In such cases, the nth DOM element will always be matched with the nth item of the array, so the bindings on that element will not be updated even when the corresponding item changes, essentially causing the view to get out-of-sync with the underlying data.

— AngularJS ng-repeat API Reference

If you are working with objects that have a unique identifier property, you should track by this identifier instead of the object instance. Should you reload your data later, ngRepeat will not have to rebuild the DOM elements for items it has already rendered, even if the JavaScript objects in the collection have been substituted for new ones. For large collections, this significantly improves rendering performance.

Post a Comment for "Ng-repeat Showing Irregular Behavior With One Time Binding"