具有动态命名视图的ui-router ng-repeat

时间:2014-05-10 04:56:18

标签: javascript angularjs angular-ui-router

我想用ui-router动态加载视图到手风琴中。问题是,当我在ng-repeat中按名称生成视图时,我根本无法加载视图。

我知道其他人在这里问了类似的question但是没有解决方法。

这有可能吗?

 <div class="panel panel-default" data-ng-repeat="group in groups">
   <div data-ui-view="step{{ group.number }}"></div>
 </div>

编辑:

.config(function($stateProvider, $urlRouterProvider){

    $urlRouterProvider.otherwise("/index1/id");//

    $stateProvider

        .state("index1", {
            abstract:true,
            url: "/index1",
            template: "<h1>This is index 1 abstract</h1><div ui-view></div>"
        })
        .state("index1.id", {
            url: "/id",
            template: "<h1>This is index1.id</h1>",
            controller: function($scope,$state){


            }
        })
        .state("index2", {
            abstract:true,
            url: "/index2",
            template: "<h1>This is index 2</h1><div ui-view></div>"
        })
        .state("index2.id", {
            url: "/id",
            template: "<h1>This is index 2.id</h1>" ,
            controller: function($scope,$state){


            }
        });
})

编辑:我创建了一个fiddle。我尝试在转发器完成后加载一个命名视图,但它不起作用。我只需要一些帮助就可以让我开始这个。

1 个答案:

答案 0 :(得分:1)

直到现在,ui-router还没有支持插值的ui-view名称:https://github.com/christopherthielen/ui-router/commit/81f6a19a432dac9198fd33243855bfd3b4fea8c0

它还没有内置到发行版中,但您可以下载源代码并构建它。