'Could not resolve state to state' 的另一个问题
Yet another issue with 'Could not resolve state to state'
我正在使用 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
状态,我有一个link:
<a ui-sref="app.user.services">
Service Integrations
</a>
但是,当我点击它时,出现错误:Error: Could not resolve 'app.user.services' from state 'app'
我做错了什么?
点.
符号用于指定ui-router
中的父关系,因此状态dashboard
的父是状态app
。
app.user.services
没有父状态 app.user
。所以你需要定义它(你可以使它抽象):
.state("app.user", {
abstract: true,
template: "<div ui-view></div>"
})
我正在使用 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
状态,我有一个link:
<a ui-sref="app.user.services">
Service Integrations
</a>
但是,当我点击它时,出现错误:Error: Could not resolve 'app.user.services' from state 'app'
我做错了什么?
点.
符号用于指定ui-router
中的父关系,因此状态dashboard
的父是状态app
。
app.user.services
没有父状态 app.user
。所以你需要定义它(你可以使它抽象):
.state("app.user", {
abstract: true,
template: "<div ui-view></div>"
})