md-autocomplete 在 ng-repeat 中生成相同的模型

md-autocomplete generating the same model in ng-repeat

md-autocomplete 在 ng-repeat 中生成相同的模型 如果一个变化的价值也反映在其他领域, 如何向其中添加不同的 ng 模型?

<tr ng-repeat="school in ctrl.schools" ng-if="ctrl.editAcademyToggle">
<td>
<md-input-container>
<div class="mdInputContainer">
    <md-autocomplete flex required flex-gt-sm="25"
        md-autofocus="true"
        md-selected-item="school.college_name"
        md-clear-button="false"
        md-input-name="school.college"
        md-input-minlength="3"
        md-no-cache="false"
        md-search-text="ctrl.academySearchStr"
        md-items="item in ctrl.searchAcademySchools(ctrl.academySearchStr)"     
        md-item-text="item.name">
        <md-item-template>
            <span class="item-title">
                <span> {{item.name}}, {{item.city}}, {{item.state}}, {{item.zip}}</span>
            </span>
        </md-item-template>
        <md-not-found>
            <span ng-if="ctrl.academySearchStr.length < 3">Minimum 3 Charaters</span>
            <span ng-if="ctrl.academySearchStr.length >= 3">
              Wait a few more seconds before searching again"
            </span>
        </md-not-found>
        <div ng-messages="ctrl.leadEntryForm.school.college.$error">
            <div ng-message="required">This field is required</div>
        </div>
    </md-autocomplete>
</div>
</md-input-container>
</td>
</tr>

生成的模型对所有行都是这样的:

ng-model="$mdAutocompleteCtrl.scope.searchText"

正在将您的 schools 视为数组。

您可以在其上进行映射,为搜索文本添加一个变量,而不是像这样到处使用相同的搜索文本

schools.map(function(obj){
    obj.searchText = null;
});

并在此处传递此搜索文本

md-search-text="school.searchText"