I am new is angularjs and i am trying to get the index value in ng-repeat
means i want to set md-option
value as index value my code is:
<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>
can anyone help me about this?
Add track by $index to your ng-repeat
<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 track by $index" ng-value="{{$index}}">
{{filterable_column.label}}
</md-option>
</md-select>
</md-input-container>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With