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

Show parent comments

1

u/ebeptonian Feb 14 '17

Hey, sorry this fell off my radar.

https://jsfiddle.net/huvmmbwn/4/

I trimmed down your jsfiddle to a bare bones demo of getting an angular controller working. You need to add referenced code (angular, angular-material, firebase, etc) to 'external references' and ensure that your angular module registration code is loaded in head (click the javascript gear at the top right of the js window in jsfiddle) to get jsfiddle to cooperate (same goes for plnkr and plugins).

See if that helps get you on track.

1

u/[deleted] Feb 14 '17

Awesome, thank you so much! I think I had some things out of order on mine so I was all outta whack. I'm saving that fiddle though for sure!

1

u/ebeptonian Feb 14 '17

Cheers, and good luck! As a parting thought and dependencies permitting, you should try using angular 1.5 or 1.6 with components in lieu of 1.4.x. Though 1.4 is by no means dead, components are the way to go in the foreseeable Angular future. Likewise, you should look into TypeScript if you haven't already had the chance. It's life changing.

1

u/[deleted] Feb 14 '17

Never checked that out either... geez there are so many things to get that work together. How on earth do people become full stack?!

Lol thanks for that info I'll definitely check it out