我在 Angular 应用程序中使用 ui-router 进行路由。我的页面在一个 html 中有 3 个 ui-views,如下所示
<html>
<div ui-view="header"></div>
<div ui-view="content"></div>
<div ui-view="footer"></div>
</html>
单击标题中的某些内容时,我必须将 ui-view="content"路由到第二个 ui-view="content2"。但页眉和页脚将保留。如何实现这一目标?
最佳答案
可以通过嵌套状态来解决。
$stateProvider
.state('parent', {
abstract: true,
views: {
header: {
templateUrl: 'header.html'
},
footer: {
templateUrl: 'footer.html'
},
content: {
template: '<div ui-view></div>'
}
}
})
.state('parent.child1', {
url: '/child1',
templateUrl: 'child1.html'
})
.state('parent.child2', {
url: '/child2',
templateUrl: 'child2.html'
});
关于javascript - 如果我在单个 html 中有多个 ui-view,如何替换单个 ui-view,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39615026/