$modal.open(), problem with "controller" parameter declaration

Asked

Viewed 606 times

0

I am trying to open a modal through the view, by the showModal() method, the problem is that I get an error referring to the controller declaration "editCrtl", which is very strange, since it is already loaded in the index and is perfectly created. Can someone help me?

Stacktrace:

Error: [ng:areq] http://errors.angularjs.org/1.4.3/ng/areq?p0=editCrtl&p1=not%20a%20function%2C%20got%20undefined

View controller code:

app.controller('listCtrl', function($scope, Crud, filterFilter, $modal) {

    $scope.veiculos = Crud.getList();

    $scope.currentPage = 1;
    $scope.totalItems = $scope.veiculos.length;
    // Itens por página
    $scope.entryLimit = 6;
    $scope.noOfPages = Math.ceil($scope.totalItems / $scope.entryLimit);

    $scope.$watch('search', function(newVal, oldVal) {
        $scope.filtered = filterFilter($scope.veiculos, newVal);
        $scope.totalItems = $scope.filtered.length;
        $scope.noOfPages = Math.ceil($scope.totalItems / $scope.entryLimit);
        $scope.currentPage = 1;
    }, true);

    $scope.remove = function(veiculo) {
        var index = $scope.veiculos.indexOf(veiculo);
        if (index != -1) {
            Crud.remove(index);
        }
    }

    $scope.showModal = function(veiculo) {
        var modalInstance = $modal.open({
            animation : true,
            templateUrl : './app/view/vehicle-register.html',
            controller : 'editCrtl',
            resolve : {
                veiculo : function() {
                    return veiculo;
                }
            }
        });

    };

});

Modal Controller

app.controller('editCtrl', function($scope, $modalInstance, veiculo) {    

});
  • in your controller’s statement is written like this: editCtrl and in the statement of your modal is like this: editCrtl

  • Complementing, the error link says the following: Argument 'editCrtl' is not a function, got undefined that is to say, "editCrtl é um argumento indefinido, with this you could find the problem without having to elaborate the question =D

1 answer

1

Can’t find the controller "editCrtl", I believe you spelled the name wrong. It wouldn’t be "editCtrl"?

Browser other questions tagged

You are not signed in. Login or sign up in order to post.