获得ng-repeat中的动态值

时间:2018-03-14 10:06:22

标签: angularjs

我有两个系列:

cc.tabGeneralValuesCollection = [{label: 'Creation Date', name: 'CreationDate', direction: 'asc', type: 'DATETIME'},    
                            {label: 'Modifier', name: 'Modifier', direction: 'asc', type: 'STRING'},
                            {label: 'Subject', name: 'Subject', direction: 'asc', type: 'STRING'}]; 

cc.tabPropertiesValuesCollection = [{label: 'Group Permission', name: 'GroupPermission', direction: 'asc', type: 'DATETIME'},   
                        {label: 'World Permission', name: 'WorldPermission', direction: 'asc', type: 'STRING'},
                        {label: 'Object ID', name: 'ObjectID', direction: 'asc', type: 'STRING'},
                        {label: 'ACL Object Name', name: 'ACLObjectName', direction: 'asc', type: 'STRING'}];   

我必须动态指定在ng-repeat中使用哪个集合。

<div ng-repeat="col in {{selectedTab}}">                
    <span><strong>{{col.label}}</strong></span>         
</div>

变量selectedTab具有ex:&#34; tabGeneralValuesCollection&#34;的集合名称。

如何让它发挥作用?

2 个答案:

答案 0 :(得分:0)

如果selectedTab是你的$ scope对象,那么请试试这个

ng-repeat="col in selectedTab.tabGeneralValuesCollection"

但我不确定你的问题是什么意思cc

答案 1 :(得分:0)

您只需使用this关键字:

即可
<div ng-repeat="col in this[selectedTab]">                
    <span><strong>{{col.label}}</strong></span>         
</div>