angularjs - Detect a change to a paticular element of a model in angular JS -
i want if users edit membership number or role pushes save particular row gets post requested api,
http://plnkr.co/edit/plm45ulwl2zklfdpskpl?p=preview
<tr ng-repeat="user in users" id="{{ user.userid}}"> .. <td>{{ user.name}}</td> <td>{{ user.email}}</td> <td ng-click="editmemno = !editmemno" ng-show="editmemno"> {{ user.role}} </td> .. <button> save</button> .. </tr> angular.module("userlist", []).controller("usersctrl", function($scope) { var original = [{ "userid": "1", "memno": "1", "name": "asdf", "username": "max", "email": "max@gmail.com", "role": "10", "mobile": "079951334" }, .. }]; $scope.users = angular.copy(original); $scope.original = angular.copy(original); $scope.editmemno = false; $scope.editmemno = function() { $scope.editmemno = true; }; $scope.roles = ["1", "2", "9", "10"];
basically want add ng-click button, when click it post row, database on condition has been altered (i.e. dirty state). add function, like
$scope.submitrow = function( row want ){ $http.post bla bla };
and in button have
<button ng-click="sumbitrow(what put here?)"
so think question stick in submitrow parameters ng-click? , or best way want achieve?
you use $scope.$watch, allows observe 1 particular property of object , bind callback event.
http://fdietz.github.io/recipes-with-angular-js/controllers/responding-to-scope-changes.html
edit: read question again. it's still bit unclear you're asking for, differences in objects try this: https://github.com/flitbit/diff
Comments
Post a Comment