I have 3 data. What I want now is to update them all using a one button but I don't know how to start or how can I get the id of each data. When the data is updated it should alert the updated value.
Any suggestions for this? Thanks
angular.module('myApp', [])
.controller('bookCtrl', function ($scope) {
$scope.book = {
name: 'Session Invites',
friends: [{
'id': 1,
'name': 'raju'
}, {
'id': 2,
'name': 'radha'
}, {
'id': 3,
'name': 'luttappi'
}]
};
$scope.update = function (friend) {
alert(friend.name);
};
});
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app="myApp">
<div ng-controller="bookCtrl">
<div ng-repeat="friend in book.friends">
<input type="text" ng-model="friend.name" />
</div>
<input type="button" id="btn" name="btn" value="update" ng-click="update(friend)" />
</div>
</div>