I've got an AngularJS app with pages built using Smarty. The top of the page has the ng-agg
tag parameter, and basic AngualarJS templates are being compiled, and the .run
method of my my module is being run, but my controller is not being called
Start of the html
<!DOCTYPE html>
<html ng-app="myapp">
...
$routeProvider
angular.module('myapp', function($routeProvider, $locationProvider) {
$routeProvider
.when('/index.php?page=tutorial', {controller: 'MyappTutorial'})
.when('/index.php?page=home', {controller: 'MyappHome'})
.when('/index.php?page=login', {controller: 'MyappLogin'})
})
Tutorial controller
var MyappTutorial = function ($scope, $location) {
console.log('tutorial');
}
When I visit the page index.php?page=tutorial I my angular page template is built and a console.log() in my myapp.run()
method is triggered, but the tutorial controller doesn't run.
How do I go about debugging this. I'm guessing it's the routeProvider going wrong, is there a way of me checking which controller is being used, if any.
I'm not getting any errors in my javascript console.
This is running in Chrome, from a local development Ubuntu virtual machine, on a Mac.
ng-controller=MyappTutorial
type tags to each page, but I thought the route provider allowed me to avoid doing this – Willshaw Media Oct 30 '12 at 0:43