如果我在单个html中有多个ui视图,如何替换单个ui视图

萨桑克·桑卡瓦利(Sasank Sunkavalli)

我在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”。但是页眉和页脚将保留。如何实现呢?

安德烈·别洛科皮托夫(Andrei Belokopytov)

可以用嵌套状态来解决。

$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] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章