Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set default URL/route?

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'
                }
            }
        });
}])
like image 654
Webnet Avatar asked Jun 19 '13 20:06

Webnet


1 Answers

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>
like image 182
laurelnaiad Avatar answered Oct 04 '22 02:10

laurelnaiad