I have a Change Password feature on my User Control Panel that is not working. It pick's up values from input and passes them from controller to service, service receives them but when he treys to hit back-end with them the debug console returns: Cannot read property 'protocol' of undefined.
Important: Please refer to my previews question here before you write your solution to understand why I have to use fields of an object to scope input. Pleas consider that sending whole object to backend is not an option, thank you.
Form (.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);
}
};
});
Debug:
Error in console: