Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

quick-ng-repeat does not update view

I use quick-ng-repeat Quick-ng-repeat for my list to iterate because it is a huge list and I would improve performance.

Now I recognized that if I change the model, the view is not updated with this code:

<span quick-ng-repeat="item in collection track by $index" quick-repeat-list="items">
 {{ item }}
</span>

With this code

<span ng-repeat="item in collection track by $index">
 {{ item }}
</span>

every works fine. Does anyone have any idee why this happens? Thanks a lot!

like image 362
quma Avatar asked May 06 '26 01:05

quma


2 Answers

quick-ng-repeat does not implement deep watch just like ng-repeat, it implement one way binding approach. So if your model changes frequently, don't use it.

In Angular 1.2 a new addition was made to the syntax of ngRepeat: the amazingly awesome track by clause. It allows you to specify your own key for ngRepeat to identify objects by, instead of just generating unique IDs.

This means that you can change the above to be ng-repeat="task in tasks track by task.id" and since the ID would be the same in both your original tasks and the updated ones from the server – ngRepeat will know not to recreate the DOM elements and reuse them

like image 188
Kashif Mustafa Avatar answered May 09 '26 03:05

Kashif Mustafa


The Quick ng-repeat is doing one way binding ,it something similar to what we do in angularjs

<div ng-repeat="item in ::items">{{item.name}}</div>

This does not create unnecessary watches.

like image 39
maddygoround Avatar answered May 09 '26 01:05

maddygoround



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!