gpt4 book ai didi

AngularJS:如何在ng-repeat中获取索引值?

转载 作者:行者123 更新时间:2023-12-04 17:32:07 26 4
gpt4 key购买 nike

我是新来的angularjs,我想获取ng-repeat中的索引值,这意味着我想将md-option值设置为索引值,我的代码是:

<md-input-container class="md-block" flex-gt-sm>
<label>Filterable Columns</label>
<md-select ng-model="visualization.filterable_columns" ng-change="drawFilters()" multiple="true" ng-init="index = 1">
<md-option ng-repeat="filterable_column in vm.filterable_columns" value="{{index++}}">
{{filterable_column.label}
</md-option>
</md-select>
</md-input-container>

有人可以帮我吗?

最佳答案

您可以这样尝试:

<md-input-container class="md-block" flex-gt-sm>
<label>Filterable Columns</label>
<md-select ng-model="visualization.filterable_columns" ng-change="drawFilters()" multiple="true">
<md-option ng-repeat="filterable_column in vm.filterable_columns" ng-value="{{$index}}">
{{filterable_column.label}}
</md-option>
</md-select>
</md-input-container>

关于AngularJS:如何在ng-repeat中获取索引值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41157855/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com