1
votes

I am using Angular v1.4.2, and keep getting "Error: [ng:areq] Argument 'accountRegisterCtrl' is not a function, got undefined" below is my controller defination

(function(app) {

    'use strict';

    function accountRegisterCtrl($scope, $window) {

       //........

        $scope.previous = function () {
            $window.history.back();
        }
    }

    app.controller('accountRegisterCtrl', ['$scope', '$window', accountRegisterCtrl]);

}(angular.module('accountRegister')));

can any body be of help!

1
Just use an inline function instead and you'll get rid of the problem.Chrillewoodz

1 Answers

0
votes

This error occurs in general if you misspeled the controller from your HTML view or your route definitions :

<div data-ng-controller="accountRegisterCtl"> <!-- WRONG -->
    // ui stuff ...
</div>

Here the accountRegisterCtl controller is called during the compilation step, but it didn't exists because its misspelled: accountRegisterCtrl is the correct controller name.

<div data-ng-controller="accountRegisterCrtl"> <!-- CORRECT -->
    // ui stuff ...
</div>

Or your controller.js is not injected in your index.html