Neph
Neph

Reputation: 418

routes in AngularJS and Angular versions

angular.module('appPTracker', ['ui.bootstrap', 
'appPTracker.filters',
'appPTracker.services',
'appPTracker.directives',
'appPTracker.controllers',
'ngGrid']).
config(["$routeProvider", function($routeProvider) {
$routeProvider.when('/', {
    templateUrl: 'partials/main.html', controller: 'ctlPTracker'});
$routeProvider.when('/admin',
    {templateUrl: 'partials/admin.html', controller: 'ctlAdmin'});
$routeProvider.otherwise({redirectTo: '/'});
}]);

I have a problem whereby the routing fails ([$injector:modulerr]) if I attempt to use a version above 1.1.4. Obviously I'm doing something wrong, but I'm not sure what needs updating. I didn't see anything specific to this in the notes...I can provide more source if it's relevant, but it's a pretty generic setup.

Upvotes: 0

Views: 809

Answers (1)

Jesus Rodriguez
Jesus Rodriguez

Reputation: 12018

Angular 1.2 is more modular now. So some parts of it are now an independent piece of code.

ngRoute is now one of them.

You need to download it first:

http://code.angularjs.org/1.2.0/angular-route.js

Load it after angular and then you need to import ngRoute like this:

angular.module('appPTracker', ['ui.bootstrap', 
'appPTracker.filters',
'appPTracker.services',
'appPTracker.directives',
'appPTracker.controllers',
'ngGrid',
'ngRoute'])

Worth saying that there are alternatives to ngRoute that worths checking like:

ui-router

Maybe doesn't work to rework all your routes, but maybe you can check it for a future project :)

Upvotes: 2

Related Questions