I'm implementing AngularUI's routing and appear to be missing something about how to configure a default URL. It seems like the below code would default the user to /dashboard/tree
but if I refresh the page, the url appends another /dashboard
, so I end up with /dashboard/dashboard/dashboard/dashboard/tree
.
How can I properly set the default URL without having this appending issue when the user first visits the page?
config(['$urlRouterProvider', '$stateProvider', function($urlRouterProvider, $stateProvider) {
$urlRouterProvider.otherwise('/dashboard/tree');
/* URL mappings */
$stateProvider.
state('dashboard', {
url: '/dashboard',
views: {
'page': {
templateUrl: '/partials/admin/dashboard.htm'
}
}
}).
state('dashboard.tree', {
url: '/tree',
views: {
'content': {
templateUrl: '/partials/admin/tree-overview.htm'
}
}
});
}])
Believe it or not, this is probably a bug/feature in angular 1.1.5 (reloads add stuff to the url).
Try setting this in your head:
<base href="/"></base>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With