{"size": 934, "ext": "js", "max_stars_repo_path": "projetoFinal/src/main/webapp/js/controllers/CategoriaController.js", "max_stars_repo_name": "dudasc/projetoFinal", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "projetoFinal/src/main/webapp/js/controllers/CategoriaController.js", "max_issues_repo_name": "dudasc/projetoFinal", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "projetoFinal/src/main/webapp/js/controllers/CategoriaController.js", "max_forks_repo_name": "dudasc/projetoFinal", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 26.6857142857, "max_line_length": 68, "alphanum_fraction": 0.4871520343}
'use restrict'

function CategoriaController($scope, Categoria) {
    
    $scope.limpar = function () {
        $scope.categoria = {};
    };

    $scope.listar = function () {
        Categoria.query().then(function (data) {
            $scope.listaCategorias = data;
        }, function (error) {
            console.log('error', error);
            alert(error.data);
        });
    };
    
    $scope.gravar = function () {       
        
        
        new Categoria($scope.categoria).create()
                .then(function () {
                    $scope.msgOk = "Cadastro realizado com sucesso";
                    $scope.limpar();
                }, function (error) {
                    $scope.msgErro = "Erro ao efetuar cadastro";
                    console.log('error', error);
                });
    };
    
    $scope.limpar();
    $scope.listar();
}
app.controller('CategoriaController', CategoriaController);
