Can you clarify what you want to achieve? As far as I understand, you get an array of objects from the server as your model. Then this is not clear:
- Do you want to check if some objects in the array have been changed (maybe since the last server call in case you are repeating Pools)?
- Do you want to check if any objects in the array have been modified by the user through some foreground controls?
In case 1, you really do not need to use $ watch (or rather $ watchCollection), but you should iterate over the array received from the server and check for changes (the same as $ watchColleciton). If the object is different from the object that you are currently using, you call the object. $ Save () for this item.
In case 2, use $ watchCollection () in the $ scope passed as a parameter to your utility function, or use $ rootScope if you are holding your array in $ rootScope.
I can provide you real code if you clarify the scripts.
Alexander Burakevych Mar 25 '14 at 1:51 2014-03-25 01:51
source share