我有我的用户控制面板更改密码功能,不能正常工作。 它挑选的最多值从输入和控制器服务并将它们传递,服务接收他们,但是当他treys打后端与他们调试控制台的回报:无法读取属性未定义的“协议”。
重要提示:请参阅我的预览问题在这里 ,你写你的解决方案,以了解为什么我必须使用对象的领域范围输入之前。 普莱斯认为发送整个对象到后端是不是一种选择,谢谢。
表格档案(.html):
<accordion-group heading="Change password" is-open="changePasswordStatus.open" style="cursor: pointer">
<div>
<div>
<form class="form-horizontal" role="form">
<form-row model="password.newPassword" name="New: " size="col-sm-8"></form-row>
<form-row model="password.repeatedNewPassword" name="Repeat: " size="col-sm-8"></form-row>
<form-row model="password.currentPassword" name="Current: " size="col-sm-8"></form-row>
<br>
</form>
</div>
<div>
<button class="btn btn-default btn-sm" data-ng-click="changePassword()">Save</button>
<button class="btn btn-warning btn-sm" ng-click="changePasswordStatus.open = !changePasswordStatus.open">Cancel</button>
</div>
</div>
</accordion-group>
userController.js:
collectionsApp.controller('userController', function($scope, userService, $timeout, $state) {
$scope.password = {
newPassword : "",
repeatedNewPassword : "",
currentPassword : ""
}
$scope.init = function() {
userService.getCurrentUser(getCurrentUser);
}
$scope.changePassword = function() {
if ($scope.password.newPassword === $scope.password.repeatedNewPassword) {
userService.changePassword($scope.password.newPassword, $scope.password.currentPassword);
}
}
...
userService.js:
collectionsApp.service('userService', function($http) {
return {
changePassword : function(newPassword, currentPassword) {
$http.post('/user/changePassword', newPassword, currentPassword);
}
};
});
调试:
错误控制台: