Error: [ng:areq] Argument 'xController' is not a function, got undefined

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!


ANSWERS:


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



 MORE:


 ? AngularJs: Error: [ng:areq] Argument 'fn' is not a function, got undefined
 ? Error: [ng:areq] Argument 'meetupsController' is not a function, got undefined
 ? pass function name to function with JSON
 ? pass function name to function with JSON
 ? pass function name to function with JSON
 ? pass function name to function with JSON
 ? how to pass a function name via JSON and call it in javascript/jQuery?
 ? what's the difference between var function and function in javascript?
 ? what's the difference between var function and function in javascript?
 ? what's the difference between var function and function in javascript?