Default route for angular ui router

后端 未结 6 2332
死守一世寂寞
死守一世寂寞 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 do it this way:

    angular.module('MyApp', ['ui.router']).config([
      '$stateProvider', function ($stateProvider) {
         $stateProvider.state('default', {
         controller: 'MyController',
         templateUrl: 'path/to/index.html',
         url:''
      })
    )];
    

    That way whenever the url is on the root of your site ui-router will capture it on a state that matches, in this case, 'default'.

提交回复
热议问题