AngularJS UI的引导键盘缓冲没有匹配 [英] AngularJS UI-Bootstrap Typeahead no matches

查看:189
本文介绍了AngularJS UI的引导键盘缓冲没有匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在寻找这样左右,但发现与这个毫无疑问。

I've been searching around so but found no question relating to this.

我采用了棱角分明的UI引导预输入。

I am using Angular UI-bootstrap typeahead.

所以我有

<input type="text" ng-model="loc" typeahead="location for location in filteredLocations = (locations | filter:$viewValue)" class="form-control" placeholder="Location" />

当我键入它显示了预输入,弹出DIV的选项。但是,我应该怎么办展现,当没有比赛,在那同样弹出没有找到匹配?

When I type it shows the options in the typeahead-popup div. But what should I do to show, when there are no matches, on that same popup "No matches found"?

在此先感谢

推荐答案

你可以做的是建立自己的成果清单。在使用很容易预输入模板-URL =customTemplate.html

What you can do is create your own results listing. That's easy using typeahead-template-url="customTemplate.html" and this:

<script type="text/ng-template" id="customTemplate.html">
  <a>
      <img ng-src="http://upload.wikimedia.org/wikipedia/commons/thumb/{{match.model.flag}}" width="16">
      <span bind-html-unsafe="match.label | typeaheadHighlight:query"></span>
  </a>
</script>

如果没有结果,返回一个元素表示没有结果。在NG-模板,你可以把NG-如果它检查,如果是无结果的元素,使之不能点击。这样,用户就不能选择没有结果。

If there are no results, return one element indicating there's no result. In the ng-template you can put a ng-if which checks if it's the no-results element and make it not clickable. That way the user can't choose "no results".

这篇关于AngularJS UI的引导键盘缓冲没有匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆