0
我在使用多个视图的单个页面上定位嵌套视图时遇到了一些麻烦。这是我的代码。单个页面上有多个视图的多个状态
$stateProvider
.state('root', {
abstract: true,
url: '/',
views: {
'viewA': {
templateUrl: '/views/viewA.html'
},
'viewB': {
templateUrl: '/views/viewB.html'
}
}
})
.state('root.sectionA1', {
url: '',
views: {
'viewASub': {
templateUrl: '/views/viewA.Section1.html'
}
}
})
.state('root.sectionA2', {
url: '',
views: {
'viewASub': {
templateUrl: '/views/viewA.Section2.html'
}
}
})
.state('root.sectionB1', {
url: '',
views: {
'viewBSub': {
templateUrl: '/views/viewB.Section1.html'
}
}
})
.state('root.sectionB2', {
url: '',
views: {
'viewASub': {
templateUrl: '/views/viewB.Section2.html'
}
}
})
我的index.html
<body>
<div ui-view="viewA"></div>
<div ui-view="viewB"></div>
</body>
HTML以我的2个部分
<!-- viewA.html -->
view A content
<div ui-view="viewASub"></div>
<!-- viewB.html -->
view B content
<div ui-view="viewBSub"></div>
此时所有viewA子视图状态显示了罚款。我可以添加多个部分,并使用ui-sref链接显示不同的状态。但是我无法看到任何'viewB'子视图。当我将'root.sectionB1'放在'root.sectionA1'上面时,第二部分子视图显示正常。我假设我需要更具体地介绍如何引用每个子视图的父级。我在这里错过了什么?
感谢您的答复。我意识到我的原始问题并不够具体,我正在寻求在单个页面上实现并行状态。它看起来像唯一可用的解决方案是使用ui-router-extras,它允许粘性状态。 – Sat