ng-repeat with two dimensional array

时间:2017-01-07 07:23:38

标签: javascript angularjs angularjs-ng-repeat

我有一个格式为

的数组
$scope.vehPermitTypevalue = [ [ "NP","National Permit"], ["IND_AP","Andra Pradesh"]];

HTML CODE:

 <ui-select name="permit" id ="permit" multiple ng-model="vehicle.selectedPermits"  on-select="getVehiclepermitId($item)"   ng-disabled="disabled" class="w-md mb-10">
    <ui-select-match placeholder="Select or search a Permit Type in the list...">{{$item[1]}}</ui-select-match>
    <ui-select-choices repeat="permittype in vehPermitTypevalue | filter:$select.search">
      <span ng-bind-html="permittype | highlight: $select.search"></span>
    </ui-select-choices>
  </ui-select>

在下拉中,我只需要“国家许可证”,“安德拉邦”,但它正在显示像NP,国家许可AP,Andra Pradesh一样下拉。

我已将我的代码更改为显示在“国家许可证”上,我确实喜欢这个

 <ui-select name="permit" id ="permit" multiple ng-model="vehicle.selectedPermits"  on-select="getVehiclepermitId($item)"   ng-disabled="disabled" class="w-md mb-10">
<ui-select-match placeholder="Select or search a Permit Type in the list...">{{$item[1]}}</ui-select-match>
<ui-select-choices repeat="permittype in vehPermitTypevalue[index][1] track by $index | filter:$select.search">
  <span ng-bind-html="permittype | highlight: $select.search"></span>
</ui-select-choices>

然后无法在下拉列表中显示任何项目。

选择任何选项后,它显示正常,如“国家许可”,带有“X”标记,以便删除{{$ item 1}}。

这里我附上照片

enter image description here

选择后,由于{{$ item 1}}

,我选择了这样的结果

enter image description here

1 个答案:

答案 0 :(得分:1)

试试这个

<ui-select-choices repeat="permittype in vehPermitTypevalue track by $index | filter:$select.search">
  <span ng-bind-html="permittype[1] | highlight: $select.search"></span>
</ui-select-choices>