cobuild-angular-stack
Version:
Base stack angular sass jade gulp
31 lines (25 loc) • 1.05 kB
JavaScript
(function (module) {
AdminDiscountSubCategoriesAddController.$inject = ['$scope', '$state', '$stateParams','$translate', 'toastr', '$uibModalInstance', 'DiscountCategory', 'discountCategory'];
module.controller('AdminDiscountSubCategoriesAddController', AdminDiscountSubCategoriesAddController);
function AdminDiscountSubCategoriesAddController($scope, $state, $stateParams, $translate, toastr, $uibModalInstance, DiscountCategory, discountCategory) {
$scope.description = "";
$scope.create = function() {
DiscountCategory.createSubcategory({
id: discountCategory.id
},{
description: $scope.description
}).$promise.then(function(category) {
$translate('success-save-data').then(function(translation){
toastr.success(translation);
$uibModalInstance.close(category);
});
}, $scope.error).catch($scope.error);
}
$scope.error = function(err) {
toastr.error(err);
}
$scope.close = function() {
$uibModalInstance.dismiss('cancel');
}
}
})(angular.module('uniko.admin.discount'));