我目前正在使用Angular.JS进行小型应用程序在我看来我有以下按钮
Edit
editUser方法看起来像这样:
$scope.editUser = function (user, $event) { $scope.userToEdit = user; $mdDialog.show({ controller: DialogController, targetEvent: $event, templateUrl: '/js/modules/user/views/edit.tmpl.html', parent: angular.element(document.body), clickOutsideToClose: true, scope: $scope }) . then(function (answer) { if (answer == "save") { for (right in $scope.allSystemRightsStatements) { if ($scope.allSystemRightsStatements[right].selected) { if( $scope.userToEdit.rights==null){ $scope.userToEdit.rights = []; } $scope.userToEdit.rights.push($scope.allSystemRightsStatements[right]); } } $scope.updateUser($scope.userToEdit); } $scope.userToEdit = {}; }, function () { $scope.userToEdit = {}; }); }; $scope.updateUser = function (user) { //userService.updateUser makes a $http PUT request var promise = userService.updateUser(user); promise.then(function (result) { $mdToast.show( $mdToast.simple(result.message) .position($scope.getToastPosition()) .hideDelay(3000) ); }, function (reason) { $mdToast.show( $mdToast.simple(reason) .position($scope.getToastPosition()) .hideDelay(3000) ); }, function (update) { }); };
现在,对话框很好地显示,并且还调用了答案功能,一切都按预期进行.
但是,当我第二次单击该按钮时,不会执行editUser功能.好像在关闭对话框中删除了按钮中的onClick事件.
非常感谢任何有关解决此问题的帮助,谢谢