Files
meanTorrent/modules/users/client/controllers/admin/user.client.controller.js
Ryan Hutchison 801547602b client-side form validation with ng-messages.
remove data prefix from attributes.

fix tests
2015-08-25 02:02:18 -04:00

41 lines
1.0 KiB
JavaScript

'use strict';
angular.module('users.admin').controller('UserController', ['$scope', '$state', 'Authentication', 'userResolve',
function ($scope, $state, Authentication, userResolve) {
$scope.authentication = Authentication;
$scope.user = userResolve;
$scope.remove = function (user) {
if (confirm('Are you sure you want to delete this user?')) {
if (user) {
user.$remove();
$scope.users.splice($scope.users.indexOf(user), 1);
} else {
$scope.user.$remove(function () {
$state.go('admin.users');
});
}
}
};
$scope.update = function (isValid) {
if (!isValid) {
$scope.$broadcast('show-errors-check-validity', 'userForm');
return false;
}
var user = $scope.user;
user.$update(function () {
$state.go('admin.user', {
userId: user._id
});
}, function (errorResponse) {
$scope.error = errorResponse.data.message;
});
};
}
]);