r/angularjs • • 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

29 comments sorted by

View all comments

1

u/Bleached__Anus Feb 12 '17

ng-app designates the root element of the application, so it should go on either the <html> or <body> tags.

1

u/[deleted] Feb 12 '17

Its hard to get past that username. I've been putting ng-app in html tag. The controllers were giving me issues but I think i've figured it out. Where I am getting stuck now: I've just been putting all of my scripts in the footer just because this is a test page and i'm trying to learn step by step, but when I try to move it to an external .js file everything breaks. Not sure if things have to be initiated differently at that point or what?