Files
brewman/brewman/static/scripts/cost-center.js
Amritanshu d1a4fc1164 Updated: Angularjs to v1.2.0 final.
Updated: Loading-bar to v0.0.5
Updated: Using the $promise of function to return promises instead of $q and callback function.
2013-11-12 00:29:23 +05:30

43 lines
1.3 KiB
JavaScript

'use strict';
var CostCenterListCtrl = ['$scope', 'cost_centers', function ($scope, cost_centers) {
$scope.info = cost_centers;
}];
CostCenterListCtrl.resolve = {
cost_centers: ['CostCenter', function (CostCenter) {
return CostCenter.query({}).$promise;
}]
};
var CostCenterCtrl = ['$scope', '$routeParams', '$location', 'cost_center', function ($scope, $routeParams, $location, cost_center) {
$scope.cost_center = cost_center;
$scope.save = function () {
$scope.cost_center.$save(function (u, putResponseHeaders) {
$scope.toasts.push({Type: 'Success', Message: ''});
$location.path('/CostCenters')
}, function (data, status) {
$scope.toasts.push({Type: 'Danger', Message: data.data});
});
};
$scope.delete = function () {
$scope.cost_center.$delete(function (u, putResponseHeaders) {
$scope.toasts.push({Type: 'Success', Message: ''});
$location.path('/CostCenters')
}, function (data, status) {
$scope.toasts.push({Type: 'Danger', Message: data.data});
});
};
$('#txtName').focus();
}];
CostCenterCtrl.resolve = {
cost_center: ['$route', 'CostCenter', function ($route, CostCenter) {
var id = $route.current.params.id;
return CostCenter.get({id: id}).$promise;
}]
};