35 lines
1.2 KiB
JavaScript
35 lines
1.2 KiB
JavaScript
angular
|
|
.module('overlord')
|
|
.controller('CostCentreController', CostCentreController);
|
|
|
|
CostCentreController.$inject = ['$scope', '$routeParams', '$location', 'costCentre'];
|
|
function CostCentreController($scope, $routeParams, $location, costCentre) {
|
|
$scope.costCentre = costCentre;
|
|
|
|
$scope.save = function () {
|
|
$scope.costCentre.$save(function (u, putResponseHeaders) {
|
|
$scope.toasts.push({Type: 'Success', Message: ''});
|
|
$location.path('/CostCentres')
|
|
}, function (data, status) {
|
|
$scope.toasts.push({Type: 'Danger', Message: data.data});
|
|
});
|
|
};
|
|
|
|
$scope.delete = function () {
|
|
$scope.costCentre.$delete(function (u, putResponseHeaders) {
|
|
$scope.toasts.push({Type: 'Success', Message: ''});
|
|
$location.path('/CostCentres')
|
|
}, function (data, status) {
|
|
$scope.toasts.push({Type: 'Danger', Message: data.data});
|
|
});
|
|
};
|
|
$scope.foName = true;
|
|
}
|
|
|
|
CostCentreController.resolve = {
|
|
costCentre: ['$route', 'CostCentre', function ($route, CostCentre) {
|
|
var id = $route.current.params.id;
|
|
return CostCentre.get({id: id}).$promise;
|
|
}]
|
|
};
|