【问题标题】:UI-router abstract state with no url没有 url 的 UI-router 抽象状态
【发布时间】:2016-01-02 21:34:07
【问题描述】:

使用 UI-Router 定义抽象状态的方法如下:

.config(function($stateProvider, $urlRouterProvider) {

  $urlRouterProvider.otherwise('/blog/home');

  $stateProvider

  // abstract state
  .state('blog', {
    url: '/blog',
    templateUrl: '/templates/navbar.html',
    abstract: true,
    controller:'NavBarCtrl as navbar',
  })

  // home
  .state('blog.home', {
    url: '/home',
    templateUrl: '/templates/home.html',
    controller:'HomeCtrl as home',
  })

 ...
})

当您导航到州主页时,您将转到域:

yourcustomdomain.com/blog/home

有没有办法定义抽象状态的url,使其不显示前缀blog,因此:

yourcustomdomain.com/home?

【问题讨论】:

    标签: angularjs angular-ui-router


    【解决方案1】:

    只需从抽象状态中删除 url

    .state('blog', {
      url: '',
      templateUrl: '/templates/navbar.html',
      abstract: true,
      controller:'NavBarCtrl as navbar',
    })
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-04-28
      • 1970-01-01
      相关资源
      最近更新 更多