8

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' } } }); }]) 
1
  • 1
    Try this : .otherwise({redirectTo: "/dashboard/tree"}) Commented Jun 19, 2013 at 20:34

1 Answer 1

5

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> 
Sign up to request clarification or add additional context in comments.

2 Comments

Having the base tag keeps the URL from appending to itself. However when my base is /admin I still have to include /admin in routing for AngularUI
Yes, that makes sense. The whole appBase base thing is in motion. See github.com/angular/angular.js/pull/2969 . I'm trying to stay abreast and informed on how this will pan out.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.