另一个问题是'无法解决州与州之间'

时间:2015-04-02 13:20:03

标签: angularjs angular-ui-router

我正在使用ui-router,我的州是:

$stateProvider.state('app', {
  url: "/app",
  templateUrl: "assets/views/app.html",
  abstract: true
}).state('app.dashboard', {
  url: "/dashboard",
  templateUrl: "assets/views/pages_timeline.html",
  title: 'Dashboard',
  controller: 'TimelineCtrl'
}).state('app.user.services', {
  url: "/user/services",
  templateUrl: "assets/views/user_services.html",
  title: 'Service Integrations'
})
.state('login', {
  url: '/login',
  template: '<div ui-view class="fade-in-right-big smooth"></div>',
  abstract: true
}).state('login.signin', {
  url: '/signin',
  templateUrl: "assets/views/login_login.html",
  controller: 'AuthenticationCtrl'
}).state('login.forgot', {
  url: '/forgot',
  templateUrl: "assets/views/login_forgot.html"
}).state('login.registration', {
  url: '/registration',
  templateUrl: "assets/views/login_registration.html"
})

我目前处于app.dashboard状态,我有一个链接:

            <a ui-sref="app.user.services">
                Service Integrations
            </a>

然而,当我点击它时,我收到一个错误:Error: Could not resolve 'app.user.services' from state 'app'

我做错了什么?

1 个答案:

答案 0 :(得分:1)

.表示法用于指定ui-router中的父关系,因此状态dashboard的父级为州app

使用app.user.services时,没有父状态app.user。所以你需要定义它(你可以把它抽象化):

.state("app.user", {
   abstract: true,
   template: "<div ui-view></div>"
})