After having checked various Stackoverflow resources, it looks like I am still unable to figure out the Angular way of doing this. The HTML table, which has just an Id column and another text column (input box), is dynamically populated via ng-repeat. Then I provide "update" and "delete" functions/buttons for each individual record showing inside input box. 'Delete' function seems OK, on 'delete' button click I just pass the ID to the function as argument. With 'update' click event, I am not sure how to pass the value of the input box to the function as a second argument. Please see the simplified markup and code below.
<tr ng-repeat="rec in allRecords">
<td>{{rec.Id}}</td>
<td>
<button ng-click="update(rec.Id, HERE_TEXT_FROM_SIBLING_INPUT')">Update</button>
<input type="text" value="{{rec.Name}}">
<button ng-click="deleteMonitorGroup(rec.Id)">Delete</button>
</td>
And the controller
app.controller('MyCtrl', function (MyService, $scope) {
MyService.listAllRecords(function (allRecs) {
$scope.allRecords= allRecs;
});
$scope.update = function (Id, text) {
MyService.update(Id, text, function () {
// update record
});
}
});
Any help is appreciated.