我在Angular App中使用ui-router进行路由。我的页面在单个html中有3个ui视图,像这样
<html>
<div ui-view="header"></div>
<div ui-view="content"></div>
<div ui-view="footer"></div>
</html>
标题中某物的onClick,我必须将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'
});
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句