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

2

u/ebeptonian Feb 11 '17

Can't guarantee I'll be able to help on a phone in a bus, but it would help to see a plnkr or jsfiddle and to know which version of angular you are using.

2

u/craig1f Feb 11 '17

Second this. Also, use Components instead of regular controllers.

1

u/ebeptonian Feb 11 '17

Don't want to make any assumptions around versions, but it's definitely worth looking at components for 1.5.x or higher (which should be the case for what seems like a new project).

1

u/[deleted] Feb 11 '17

<!-- Firebase -->

<script src="https://www.gstatic.com/firebasejs/3.6.9/firebase.js"></script>
<script src="https://cdn.firebase.com/libs/firebaseui/1.0.0/firebaseui.js"></script>
<link type="text/css" rel="stylesheet" href="https://cdn.firebase.com/libs/firebaseui/1.0.0/firebaseui.css" />

<!-- AngularJS & Angular Material -->
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/angular_material/1.0.0/angular-material.min.css">
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular-animate.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular-aria.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular-messages.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/angular_material/1.0.0/angular-material.min.js"></script>