在角度材料演示中,当我测试自动完成浮动标签示例时,它无法正常工作并出现错误
https://material.angularjs.org/latest/demo/autocomplete
- 单击“最喜欢的状态”并单击退出>显示错误消息:确定
- 刷新页面,点击“收藏状态”,输入“xxx”并点击退出 > 显示错误信息:OK
- 现在,不要刷新 ant 重置字段 > 没有错误消息,但该字段是红色的:不适合我,我本来希望出现必需的消息错误
- 再次输入“xxx”,没有错误信息
您是否有使错误消息正常工作的解决方案?
plunker 示例: https : //plnkr.co/edit/AmTLs4mbRsxgSNjEKvhn md-autaucomplete 字段的代码
<md-autocomplete flex required
md-input-name="autocompleteField"
md-input-minlength="2"
md-input-maxlength="18"
md-no-cache="ctrl.noCache"
md-selected-item="ctrl.selectedItem"
md-search-text="ctrl.searchText"
md-items="item in ctrl.querySearch(ctrl.searchText)"
md-item-text="item.display"
md-require-match
md-floating-label="Favorite state">
<md-item-template>
<span md-highlight-text="ctrl.searchText">{{item.display}}</span>
</md-item-template>
<div ng-messages="searchForm.autocompleteField.$error" ng-if="searchForm.autocompleteField.$touched">
<div ng-message="required">You <b>must</b> have a favorite state.</div>
<div ng-message="md-require-match">Please select an existing state.</div>
<div ng-message="minlength">Your entry is not long enough.</div>
<div ng-message="maxlength">Your entry is too long.</div>
</div>
</md-autocomplete>
谢谢