%PDF- %PDF-
Direktori : /var/www/html/news/public/scripts/controllers/categories/ |
Current File : /var/www/html/news/public/scripts/controllers/categories/category.controller.js |
'use strict'; angular.module('controllers').controller('categoryController', function ($scope, category, resource, notification, autoCompleteService) { $scope.isNew = !category; $scope.getCategories = autoCompleteService.getCategories; if ($scope.isNew) { $scope.category = {}; } else { $scope.category = category; } $scope.save = function () { $scope.category.parent_id = $scope.category.parent ? $scope.category.parent.id : null; if ($scope.isNew) { resource.forResource('categories').save($scope.category).then(function (res) { notification.success('Category created successfully'); $scope.back(); }, function (error) { notification.error(error) }); } else { resource.forResource('categories').update($scope.category.id, $scope.category).then(function (res) { notification.success('Category updated successfully'); $scope.back(); }, function (error) { notification.error(error) }); } }; $scope.back = function () { history.back(); }; });