Reputation: 786
I have a very simple Angular controller set up, but the code inside its constructor isn't running. Here are the relevant pieces:
conversationcontrollers.js:
var exampleApp = angular.module('exampleApp',[]);
console.log('file loaded');
exampleApp.controller('ConversationController', ['$scope',
function($scope) {
console.log('controller constructor loads');
}
]);
conversation.html:
...
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.1.5/angular.min.js"></script>
<script src='/static/js/conversationcontrollers.js'></script>
...
<div ng-controller="ConversationController">
</div>
...
The files both load correctly according to the browser. But the only results from the console are:
file loaded
Can anyone help?
Upvotes: 0
Views: 1833
Reputation: 12887
You'll also need an ng-app. This tells angular which part of your page is the angular application.
<div ng-app="exampleApp" ng-controller="ConversationController">
</div>
Upvotes: 3