I have a data object "data" as below, but i need to iterate them over the other array called "values", and when I update the values in view inputs, i need to update the model object "data" accordingly,
but the problem is index "b" is not defined in "data" object as inxdex "a" so how can i update "data" object in controller, for all the "values" array indexes including "b" which is not yet defined in "data" object. is there any alternative method for this kind of scenario?
controller
$scope.values=["a","b"];
$scope.data={"a":{name:"A"}};
$scope.updateRate = function(val) {
$scope.data[val]=//i want the input value here;
};
view
<tr ng-repeat="v in values">
<td><input ng-model="data[v].name" type="text" ng-blur="updateRate(v)"></td>
</tr>
data[v].name, since that's what you've bound tongModel? Otherwise, have you tried using$event? As inupdateRate($event, v)