Angular-bootstratp ui typeahead没有匹配的结果

prd*_*uty 1 angularjs bootstrap-typeahead angular-ui-bootstrap

嗨我在我的angularjs网站使用bootstrap ui typeahead.这非常有效.只是想知道当用户输入不在列表中的内容时是否可以显示"找不到匹配项"等文本.

MLB*_*des 8

typeahead指令包含一个属性,typeahead-no-results.

这是一个例子:

<input type="text" ng-model="asyncSelected" placeholder="Placeholder Text" typeahead="address for address in getLocation($viewValue)" typeahead-no-results="noResults" class="form-control">
Run Code Online (Sandbox Code Playgroud)

然后使用ng-if或ng-show显示错误消息.

<div ng-if="noResults">
  No Results Found!
</div>
Run Code Online (Sandbox Code Playgroud)

有关更多阅读材料,请务必查看bootstrap-ui文档

  • 这可能不言而喻,但如果页面上有两个或更多的Typeaheads,设置typeahead-no-results ="noResults"将导致所有这些都显示出来.因此,如果您希望它们独立运行,请设置typeahead-no-results ="noResultsA",typeahead-no-results ="noResultsB"等. (2认同)