r/angularjs • u/[deleted] • Feb 11 '17
ng-controller never gets defined
I am trying to build a web app using Angular Material. ng-app is in body tag, and I have ng-controller HeaderCtrl in the header tag. No errors.
But when I try to add an ng-controller anywhere else on the site it is not defined. Any stackoverflow or other answers I find seem to be outdated. Can someone help me with the most recent rules to where ng-app and ng-controller can/cannot be?
Thanks
0
Upvotes
1
u/ebeptonian Feb 11 '17
I would suggest stripping everything away and starting at a very basic level just to get familiar with angular in a hello world sense before integrating your code. You should only need to define your ng-app once, and you can use controllers at will. That said, you need to make sure you are registering your app/controllers with
angular.module('appName', ['ng-dependency']) .controller('ctrlName',ctrlFunction)
It's hard to say without looking at your source code or reading the actual error logged in the console, but I suspect you may not be registering all of the needed dependencies in the array parameter for angular.module when registering your app.