Here ya go: http://plnkr.co/edit/xAgm0ny6yAB8spd5Oiai?p=preview
You could probably simplify this and store the original values in hidden fields to see if they changed and reduce it to just one update button per repeat, but this is a start!
<div ng-repeat="(k,v) in myCtrl.myObject">
<input type="hidden" ng-model="k">
<div>
Key: <input ng-model="newKey" ng-value="k" />
<button ng-click="myCtrl.updateKey(k, newKey, v)">Update</button>
</div>
<div>
Value: <input ng-model="v" />
<button ng-click="myCtrl.updateValue(k,v)">Update</button>
</div>
<hr />
</div>
and the functions:
vm.updateKey = function(k, newKey, v) {
// newKey will be undefined if nothing changed
// Check to see if it changed
if(k != newKey && newKey !== undefined) {
// If it's empty... delete it
if(newKey != '') {
vm.myObject[newKey] = v;
}
delete vm.myObject[k];
}
};
vm.updateValue = function(k, v) {
vm.myObject[k] = v;
};
Some other considerations you should take into account are: what if the new property name conflicts with another? Also - my comment above about setting it to undefined isn't sufficient. You need to use the delete keyword or else it will not update the ng-repeat properly.
updateKey(k, v)andupdateValue(k, v). In updateKey, you need to setcluster.properties[k] = undefinedand move the v to the newcluster.properties[k]. This is what comes to mind when I first think about it... It's an interesting concept. I wanna try this!