失去焦点的md-autocomplete md-require-match

时间:2017-06-07 17:38:07

标签: angularjs angularjs-material

我有一个自动完成控件(Angular Material版本1.1.2),其中md-require-match = true和验证消息

                                <md-autocomplete required
                              md-no-cache="true"
                              md-select-on-match = "true"
                              md-selected-item="vm.selectedItem"
                              md-search-text="vm.searchText"
                              md-items="country in vm.querySearch(vm.searchText)"
                              md-item-text="country.nm"
                              md-min-length="2"
                              md-selected-item-change="vm.updateOrgCountry(country.cd)"
                              md-require-match = "true"
                              md-input-name="countryField"
                              md-match-case-insensitive = "true"
                              md-floating-label="Country">
                              <md-item-template>
                                 <span md-highlight-text="vm.searchText" md-highlight-flags="^i">{{country.nm}}</span>
                              </md-item-template>
                              <md-not-found>
                                    No Countries matching "{{vm.searchText}}" were found.
                              </md-not-found>
                              <div ng-messages="orgForm.countryField.$error">
                                <div ng-message="required"></div>
                                <div ng-message="md-require-match">Country not found.</div>
                              </div>
                           </md-autocomplete>

当我第一次进入控件并开始输入时,一切都按预期工作。如果我没有从列表中选择一个项目,然后离开控件,我会收到“找不到国家/地区”错误消息。

但是,如果我回到控件并再次开始输入,则每次按键后都会收到“未找到国家/地区”错误消息,直到我从列表中选择某些内容。我不想要这种行为,因为用户在输入数据时应该看到错误。

有没有办法将自动完成控件配置为仅在控件失去焦点时验证匹配?

0 个答案:

没有答案
相关问题