Reputation: 7809
I have created a website which uses angular-ui-router for mapping to multiple views. Everything works fine except for two things:
$urlRouterProvider.otherwise()
value. The view is not altered though.My main module looks like this:
angular.module('package.name', [
'ui.router',
'ui.bootstrap',
'package.nameControllers'
]).
config(function($stateProvider, $urlRouterProvider) {
$stateProvider.
state('home', {
url: 'home',
templateUrl: 'templates/home.html',
controller: 'homeCtrl'
}).
state('other', {
url: 'other',
template: 'Another page'
});
$urlRouterProvider.otherwise('/home');
});
What am I doing wrong?
I have created the same situation on this plunkr. The example of the url not changing can be seen here.
Upvotes: 2
Views: 1394
Reputation: 2935
Urls for top level states should begin with a slash. Try adding the slash:
state('home', {
url: '/home',
templateUrl: 'templates/home.html',
controller: 'homeCtrl'
}).
state('other', {
url: '/other',
template: 'Another page'
});
See here.
Upvotes: 4