The argument is not aNaNunction, received undefined

I go from AngularJS 1.2.26 to 1.3.2 and get Error

Not the best error message for development, but it looks like it says my controller is undefined? Can I no longer define controllers this way?

Error: Error: areq

Bad argument

The argument 'welcomeController' is not aNaNunction, received undefined

My index page looks something like this:

<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.2/angular.min.js"></script> <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.2/angular-route.min.js"></script> <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.2/angular-sanitize.min.js"></script> var myApp = angular.module('kioskApp', ['ngRoute','ngSanitize']).run(function($rootScope, $location, $timeout) { $rootScope.authenticated = true; }); myApp.config(function($routeProvider, $locationProvider, $sceDelegateProvider) { $routeProvider .when('/welcome', { templateUrl : 'pages/welcome.php', controller : 'welcomeController' }); }); function welcomeController($rootScope, $scope, $http, $location) { //stuff } 

My welcome page looks something like this:

 <div ontouchmove="preventDrag(event)" ng-show="authenticated"> <!-- some images --> </div> 
+5
source share
1 answer

You can use controller: welcomeController (without quotes) to use it as a function. Otherwise, do something like myApp.controller('welcomeController', welcomeController) .

You should also learn the syntax for dependency injection.

+2
source

Source: https://habr.com/ru/post/1206527/


All Articles