I am dealing with an array of objects structured like this:
$scope.rows =
[{
num1: 56,
num2: 78,
num3: 89
}, {
num1: 56,
num2: 78,
num3: 89
}, {
num1: 56,
num2: 78,
num3: 89
}, {
num1: 56,
num2: 78,
num3: 89
}];
I have created a table using ng-repeat:
<div id="structure">
<table border='1|1'>
<tr ng-repeat="item in rows">
<td>
<span ng-hide="item.editing" ng-dblclick="editItem(item)">{{item.num1}}</span>
<input ng-show="item.editing" ng-blur="doneEditing(item)" autofocus/>
</td>
<td>
<span ng-hide="item.editing" ng-dblclick="editItem(item)">{{item.num2}}</span>
<input ng-show="item.editing" ng-blur="doneEditing(item)" autofocus/>
</td>
<td>
<span ng-hide="item.editing" ng-dblclick="editItem(item)">{{item.num3}}</span>
<input ng-show="item.editing" ng-blur="doneEditing(item)" autofocus/>
</td>
</tr>
</table>
</div>
Functions for editing:
$scope.editItem = function (item) {
item.editing = true;
};
$scope.doneEditing = function (item) {
item.editing = false;
};
The issue I'm facing is that all keys have the same name in each object, how can I implement double-click functionality to update the table values?