小编San*_*an-的帖子

角度路由ui-view在另一个ui-view中

概念概述:

我们在索引html上有两个标签.我们在那里路由那些标签:

<div ui-view></div>
Run Code Online (Sandbox Code Playgroud)

在第二个选项卡上,我们有一个选择器,在另一个ui视图中切换选项卡的内容,如下所示:

<div ui-view="{{vm.currentView}}"></div>
Run Code Online (Sandbox Code Playgroud)

其中vm.currentView是路由状态的名称('book1'等).

 .state('tab2', {
        abstract: true,
        templateUrl: 'tab2.html',
        controller: 'Tab2Controller',
        controllerAs: 'vm'
    })
    .state('tab2.content', {
        url: '/tab2',
        views: {
            '': {
                templateUrl: 'tab2.html'
            },
            'book1@tab2': {
                templateUrl: 'tab2-book1.html'
            },
            'book2@tab2': {
                templateUrl: 'tab2-book2.html'
            },
            'book3@tab2': {
                templateUrl: 'tab2-book3.html'
            },
            'book4@tab2': {
                templateUrl: 'tab2-book4.html'
            }
        }
    });
Run Code Online (Sandbox Code Playgroud)

一切都很好,除了一件事:数据内容和视图名称正在改变,但模板内容不是.

我通过另一种方式解决了这个问题(基于排除'ui-view in another ui-view'概念和单独的状态视图).但我仍然想知道:"如何使用'ui-view inside ui-view'概念来做到这一点?"

这是一个Plunker示例

angularjs angular-ui-router

15
推荐指数
1
解决办法
2万
查看次数

标签 统计

angular-ui-router ×1

angularjs ×1