I'm migrating from AngularJS 1.2.26 to 1.3.2 and receive an Error
Not the best error message to work out but it looks like it is saying that my controller is not defined? Can I no longer define controllers this way?
Error: error:areq
Bad Argument
Argument 'welcomeController' is not aNaNunction, got undefined
My index page is something like:
<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 is something like:
<div ontouchmove="preventDrag(event)" ng-show="authenticated">
<!-- some images -->
</div>
You could use controller: welcomeController
(without the quotes) to use it as a function. Otherwise, do something like myApp.controller('welcomeController', welcomeController)
.
You should also learn the syntax for dependency injection
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With