I'm having issue getting the controllers for my routes to execute.
Basically, I register my routes as follows:
var App = angular.module('App', ['ngRoute', 'routesControllers']);
App.config(['$routeProvider',
function($routeProvider) {
$routeProvider.
when('/', {
template: " ",
controller: 'NewOrderCtrl'
}).
when('/:companyName/:orderNumber', {
template: " ",
controller: 'ViewOrderCtrl'
}).
otherwise({
redirectTo: '/'
});
}]);
Here, I am not defining anything in the template because I use my routes to fire ajax GETs.
My controllers are as follows:
var routesControllers = angular.module('routesControllers', []);
routesControllers.controller('NewOrderCtrl', ['OrderManagerFactory', function(OrderManagerFactory) {
alert('NewOrderCtrl fired!');
//create a new empty company and order
OrderManagerFactory.createNewCompany();
OrderManagerFactory.createNewOrder();
}]);
routesControllers.controller('ViewOrderCtrl', ['OrderManagerFactory', '$routeParams', function(OrderManagerFactory, $routeParams) {
alert('ViewOrderCtrl fired!');
//Fire a bunch of ajax calls using the data from $routeParams
}]);
I also put a div for my empty view:
<div ng-view ng-controller="ViewOrderCtrl"></div>
And when I visit #/tesla/x123x
for example, I get nothing. The alert() in either one of the controllers does not execute...
Can somebody help? What am I missing?