How to automatically update connected parts of json with angularjs -


I have the next Jason structure:

  {"item": [{" {"Name": "item 1"}, {"name": "item 2"}, {"name": "item 3"}], "group": [{"name": "group 1", "item" : ["Item 1" "item 3", "item": {"item2", "item": ["item 2", "item 3"]}, {"name": "group 3", "item" : ["Item 1", "item 2"]}]  

}

As you can see in your groups, I have the names of items I group There is no way in angular angles to automatically update objects, when it comes special Tom's name changes (what's the way to connect to particular parts of the json model?)

Thanks.

You can set a deep $ watch for each item in the item array. When the item changes, then repeat on the group item, and replace the old name with the new name:

  angular .forEach ($ scope.model.items, function (item) {$ scope. $ Clock (function () {return item;}, function (newwell, oldwol) {angular.forEach ( $ Scope.mode L.groups, function (group) {var item = group.im; Var item index = item.indexoff (oldname) .name); If (item index> = 0) {item [item index] = newVal.name;}});}, true);});  


Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -