以此形式为例
http://plnkr.co/edit/fHEBw6dDdG3IVgnmCLb7?p=preview
按下SAVE DRAFT按钮后,如何将表单的$pristine状态设置为true?
按下SAVE DRAFT按钮后,如何将表单的$pristine状态设置为true?
解决方法
您可以在
http://plnkr.co/edit/wXaFXtuhNH6d4SP2uArm?p=preview上打电话给
$setPristine
<button ng-click="reset(); form.$setPristine()">RESET</button> <button ng-click="update(user); form.$setPristine()">SAVE</button>
$scope.update = function(user) { $scope.master= angular.copy(user); if ($scope.form) $scope.form.$setPristine(); }; $scope.reset = function() { $scope.user = angular.copy($scope.master); if ($scope.form) $scope.form.$setPristine(); };