Default route for angular ui router

后端 未结 6 2340
死守一世寂寞
死守一世寂寞 2020-12-15 18:58

The sample demo of the angular ui router has this link for the start page:

full url of \'ui-router\' is / or http://angular-ui.github.io/ui-route

6条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-15 19:47

    You can use $urlRouterProvide.otherwise. This will work if you try to navigate to a route url that has not been defined.

    Taken from here.

    function configurUIRoutes($stateProvider, $urlRouterProvider) {
    
    $stateProvider
        .state('myhomepage',
        {
            abstract: false,
            url: '/myhomepageurl',
            templateUrl: "some-path/staff-admin.html",
            controller: 'HomeController'
        });
    
    $urlRouterProvider.otherwise('/myhomepageurl'); // User will be taken to /myhomepageurl if they enter a non-matched entry into URL
    
    }
    

提交回复
热议问题