denniss17/pimatic-angular-material-frontend

View on GitHub
app/controllers/settings/groups/create.js

Summary

Maintainability
A
2 hrs
Test Coverage
angular.module('pimaticApp.settings').controller('GroupsCreateController', [
    '$scope',
    '$location',
    'toast',
    'store',
    function ($scope, $location, toast, store) {
        $scope.group = {};

        $scope.cancel = function ($event) {
            $event.preventDefault();
            $location.path('settings/groups');
        };

        $scope.save = function () {
            store.add('groups', $scope.group).then(function () {
                $location.path('settings/groups');
            }, function (message) {
                toast.error('Saving group failed: ' + message);
            });
        };
    }
]);