I want to synchronize data, so I have a data object containing the current state. When this change, I would like to set the attribute of the object so that I can filter it during synchronization. Object structure:
data = { type1: [ {a:"a", b:"b"},... ] type2: [ {c:"c", d:"d"},... ] }
For example, if data.type1 [0] .a = "test" is executed, I would like to add a modified: true for the object so that it is
{a:"test", b:"b", modified:true}
I tried $ watch (data, function (), true), but I canβt find how I can see which object was modified, and finding both data of data objects will be a big overhead. $ watchcollection (when just looking for add / remove) also does not give an index.
Is there any way to find out which object has been modified? Or is there another library that can do this well?
thanks
EDIT:
I created jsfiddle: https://jsfiddle.net/yfo8xwah/
javascript synchronization angularjs
Peter Burkert
source share