0
votes

Error: [ng:areq] http://errors.angularjs.org/1.3.15/ng/areq?p0=homeController&p1=not%20aNaNunction%2C%20got%20undefined

I am getting the above error

Controller.js

angular.module('app').controller('homeController', function($scope) {});

app.js

 var app = angular.module('app', ['base', 'ngRoute', 'routeResolverServices']);
angular.bootstrap(document, ['app']);
return app;
1
share your html file - Dilip Kumar
wrapping angular.bootstrap(document, ['app']); in angular.element ready will solve your issue - Pankaj Parkar

1 Answers

2
votes

This doesn't work because of the order of your scripts (and wouldn't work in any order the way you defined it). When Controller.js loads first, there is is still no module named "app". When app.js loads first, it immediately bootstraps the app without the controller.

It's best to define one module per file, for example:

feature1.js

angular.module("feature1", []).controller("homeController", function(){});

app.js

var app = angular.module('app', 
             ['base', 'feature1', 'ngRoute', 'routeResolverServices']);
app.bootstrap(document, ['app']);

and load app.js last:

<script src="feature1.js"></script>
<scirpt src="app.js"></script>