Files
meanTorrent/modules/users/client/controllers/settings/edit-profile.client.controller.js
Trevor Jennings 5137214972 fix(users): Incorrect UsersService injection (#1283)
* fix bug in edit profile controller.

* fix(users): Incorrect UsersService injection
2016-04-29 14:20:03 -07:00

39 lines
975 B
JavaScript

(function () {
'use strict';
angular
.module('users')
.controller('EditProfileController', EditProfileController);
EditProfileController.$inject = ['$scope', '$http', '$location', 'UsersService', 'Authentication'];
function EditProfileController($scope, $http, $location, UsersService, Authentication) {
var vm = this;
vm.user = Authentication.user;
vm.updateUserProfile = updateUserProfile;
// Update a user profile
function updateUserProfile(isValid) {
vm.success = vm.error = null;
if (!isValid) {
$scope.$broadcast('show-errors-check-validity', 'vm.userForm');
return false;
}
var user = new UsersService(vm.user);
user.$update(function (response) {
$scope.$broadcast('show-errors-reset', 'vm.userForm');
vm.success = true;
Authentication.user = response;
}, function (response) {
vm.error = response.data.message;
});
}
}
}());