50 lines
1.4 KiB
JavaScript
50 lines
1.4 KiB
JavaScript
(function () {
|
|
'use strict';
|
|
|
|
angular.module('soter')
|
|
.controller('RoleListController', ['$scope', 'roles', RoleListController])
|
|
.controller('RoleController', ['$scope', '$location', 'role', RoleController]);
|
|
|
|
function RoleListController($scope, roles) {
|
|
$scope.info = roles;
|
|
}
|
|
|
|
function RoleController($scope, $location, role) {
|
|
$scope.role = role;
|
|
|
|
$scope.save = function () {
|
|
$scope.role.$save(function (u, putResponseHeaders) {
|
|
$scope.toasts.push({Type: 'Success', Message: ''});
|
|
$location.path('/Roles')
|
|
}, function (data, status) {
|
|
$scope.toasts.push({Type: 'Danger', Message: data.data});
|
|
});
|
|
};
|
|
|
|
$scope.delete = function () {
|
|
$scope.role.$delete(function (u, putResponseHeaders) {
|
|
$scope.toasts.push({Type: 'Success', Message: ''});
|
|
$location.path('/Roles')
|
|
}, function (data, status) {
|
|
$scope.toasts.push({Type: 'Danger', Message: data.data});
|
|
});
|
|
};
|
|
$('#txtName').focus();
|
|
}
|
|
|
|
})();
|
|
|
|
var RoleCtrlResolve = {
|
|
role: ['$route', 'Role', function ($route, Role) {
|
|
var id = $route.current.params.id;
|
|
return Role.get({id: id}).$promise;
|
|
}]
|
|
};
|
|
|
|
var RoleListCtrlResolve = {
|
|
roles: ['Role', function (Role) {
|
|
return Role.query({}).$promise;
|
|
}]
|
|
};
|
|
|