Default route for angular ui router

后端 未结 6 2342
死守一世寂寞
死守一世寂寞 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:33

    The simplest way of all

    add $urlRouterProvider service in config(function($urlRouterProvider))

    and then

    app.config(function ($stateProvider, $urlMatcherFactoryProvider, $urlRouterProvider) {
    
             $urlRouterProvider.otherwise('employeesState'); //default route
    
             $stateProvider.state('employeesState', function(){
                  //state configuration here
             }) //employees state
    
             $stateProvider.state('cutomersState', function(){
                 //state configuration here
             })
    }
    

    name any of the state in otherwise function to which you want as your default state/route

提交回复
热议问题