如果我有以下状态:
$stateProvider
.state( 'home', {
url: '/',
views: {
'dashboard-body': {
templateUrl: './modules/main-dashboard.options.html',
controller: 'MainDashboardController',
controllerAs: 'vm'
}
}
} );
它可以嵌套状态吗?...我遇到了麻烦,我有以下几种状态:
$stateProvider
.state( 'home', {
url: '/',
views: {
'dashboard-body': {
templateUrl: './modules/main-dashboard.options.html',
controller: 'MainDashboardController',
controllerAs: 'vm'
}
}
} )
.state( 'home.purchases', {
url: '/purchases',
views: {
'dashboard-body@home': {
templateUrl: './modules/purchases/purchases-dashboard.options.html',
controller: 'PurchasesDashboardController',
controllerAs: 'vm'
}
}
} );
但如果我转到home.purchases
状态,则生成的网址为:http://localhost:3000//purchases
如果home.purchases
的属性网址为:url: 'purchases'
,则会生成正确的网址http://localhost:3000/purchases
,但它不会更改视图...有任何想法吗?
答案 0 :(得分:0)
如果您的根视图(通常为index.html
)具有
ui-view="dashboard-body"
然后您的home.purchases
州需要使用
views: {
'dashboard-body@': {
// ...
}
}
否则,它会尝试将模板加载到dashboard-body
州模板(home
)中名为modules/main-dashboard.options.html
的视图中