对于ng repeat循环的每次迭代,您可以选择作为对象数组,
choice
choices
大堆你可以有如下属性
searchText
,
selectedItem
,
fieldName
在那个阵列中。我创建了自己的示例来解决您的问题,因此您的等效模板可以是:
<div ng-repeat="choice in ctrl.choices">
<md-autocomplete
md-selected-item = "choice.selectedItem"
md-search-text-change = "ctrl.searchTextChange(choice.searchText)"
md-search-text = "choice.searchText"
md-selected-item-change = "ctrl.selectedItemChange(item)"
md-items = "item in ctrl.querySearch(choice.searchText)"
md-item-text = "item.display"
md-min-length = "0"
placeholder = "US State? {{choice.fieldName}}">
<md-item-template>
<span md-highlight-text = "choice.searchText"
md-highlight-flags = "^i">{{item.display}}</span>
</md-item-template>
<md-not-found>
No states matching "{{choice.searchText}}" were found.
</md-not-found>
</md-autocomplete>
</div>
this.choices = [{searchText: '', selectedItem: '', fieldName: 'Field 1'},
{searchText: '', selectedItem: '', fieldName: 'Field 2'},
{searchText: '', selectedItem: '', fieldName: 'Field 3'}];
以下是plunker示例的链接:
https://plnkr.co/edit/hcBtQ45GUY15XUOfjEUr?p=preview