Hello!
I want the timer to refresh the list for incoming orders on the current page. Know what's cooler to do it using web sockets, but it later :) While I want so.
Data are displayed using track by with ngRepeat I read it in the docks, so angular know the exact item ID, instead of coming up with it myself, and I understand that the dataset will be updated - if the identifiers match, then the DOM of such elements won't move. But I'm not all repaints anyway :( the Data in the controller is updated:
$timeout(function () {
self.orders = Order.query();
}, 30000);
Displays like this:
...
Tell me, please, what am I doing wrong? Thank you!
$interval(function () {
Order.query(function (orders) {
angular.merge(self.orders, orders);
});
}, 30000); - tristin_Hamill38 commented on July 8th 19 at 11:40
---
If you are working with objects that have an identifier property, you should track by the identifier instead of the whole object. 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. - tanya.Bartell commented on July 8th 19 at 11:43
No, it is not affected - Bianka0 commented on July 8th 19 at 11:46
Order.query(function (orders) {
self.orders = orders;
});
but not so:
self.orders = Order.query();
Now everything is super, but for some fields on the orders page I have a input field with ngModel to some of the data could change. And the above code overwrites them stupid.
For example, I want to be able to change phone:
And when the data timer is received from the server, so I haven't peresechenii - he, respectively, is the same, but mine is overwritten.
Can't figure out how beautiful it to get around... - tristin_Hamill38 commented on July 8th 19 at 11:49
< input type="phone" data-ng-model="order.phone" > - tristin_Hamill38 commented on July 8th 19 at 11:52
In short, better web sockets, apply than to sculpt humpback :) And then the server will give only what is really new, without anything else. - tristin_Hamill38 commented on July 8th 19 at 11:58