【问题标题】:angular bootstrap typeahead filter角度引导预输入过滤器
【发布时间】:2015-01-30 07:26:57
【问题描述】:

这是一个显示我看到的问题的 plunker:

http://plnkr.co/edit/TKIHuNzPrrXlbzEdjdqN?p=preview

我想要一个用户只能从提供的选项中进行选择的预输入。我有以下 HTML:

<script src="//angular-ui.github.io/bootstrap/ui-bootstrap-tpls-0.12.0.min.js"></script>
<link rel = "stylesheet" href = "http://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css">

<input type = "text" ng-model = "receiver.value" class = "give-recipient" 
 typeahead = "user for user in users" typeahead-editable = "false">

它会显示预输入,但它过滤我输入的内容。 IOW,我希望如果我输入“g”,只有名称中带有“g”的用户才会显示,但所有用户都会显示,匹配的字母加粗。

我需要使用哪些设置?谢谢, 格雷格

【问题讨论】:

  • 如果可能请提供 fiddle 或 plunker
  • typeahead 指令 - 这是您自己的还是您使用的库?
  • 这是 Angular 引导程序。这是脚本链接
  • 我添加了一个 Plunker

标签: angularjs bootstrap-typeahead


【解决方案1】:

你需要改变

typeahead="user for user in users"

typeahead="user for user in users | filter:$viewValue "

UI Bootstrap 文档指出 $viewValue 是一个

与输入中输入的值相对应的变量

可以看到一个工作的 plunkr here

【讨论】:

  • 嗨@dorzey,对于这种情况,我们如何传递比较器函数?
  • 没关系。这很简单,正如 angularjs org 网站上给出的那样。没有变化。
猜你喜欢
  • 1970-01-01
  • 2013-03-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-03-31
  • 1970-01-01
  • 1970-01-01
  • 2016-07-18
相关资源
最近更新 更多