angular bootstrap 输入过滤器

angular bootstrap typeahead filter

这里有一个 plunker 显示了我遇到的问题:

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

我想要一个预先输入,用户只能从提供的选项中 select。我有以下 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" 的用户应该出现,但所有用户都会出现,并且匹配的字母会加粗。

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

你需要改变

typeahead="user for user in users"

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

UI Bootstrap 文档指出 $viewValue 是一个

variable that corresponds to the value entered inside the input

可以看到一个工作的 plunkr here