Angularjs Angular Typeahead不会在空白处触发

Angularjs Angular Typeahead不会在空白处触发,angularjs,autocomplete,typeahead.js,Angularjs,Autocomplete,Typeahead.js,我定义了以下控件: <input id="inputSearchMovies" type="search" ng-model="filterItems" placeholder="Search for movies ..." typeahead="prediction for

我定义了以下控件:

<input                 id="inputSearchMovies"
                       type="search"
                       ng-model="filterItems"
                       placeholder="Search for movies ..."
                       typeahead="prediction for prediction in getPredictions($viewValue) | limitTo:10"
                       typeahead-min-length='1'
                       typeahead-on-select='onSelectPart($item, $model, $label)'
                       typeahead-template-url="customTemplate.html"
                       class="form-control shortInputSearch"
                       style="width: 98% !important" />

这是引导到
getPredictions
函数的,该函数在输入I时执行调用

问题是,当我输入空格时,不会调用typeahead机制:

  • “阿拉伯的劳伦斯”->键入“i”,工作正常(调用预测函数):“阿拉伯的劳伦斯”
  • “Lawrence of Arab”->键入空格不会导致任何预测调用:“Lawrence of Arab”(未调用服务器)

如何修复它以对每个字符更改执行调用(是否为空白)

您的问题实际上并不是来自
ui引导
,而是来自角度处理
输入
s的方式。在设置
ng model
的值之前,它会自动修剪
输入的值。由于该值最终与以前相同(因为它被修整),所以它不认为这是一个值的改变,因此它不调用<代码> NGMODELMODER  <代码> $Passs<代码>,这就是用于触发它的“GETMatcSeSycNC”(或您的“Type Debug机制”)。p>
不过,不要担心,使用
ng trim
可以关闭此功能,如下所示:

<input typehead... ng-trim="false"></input>

在Arguments
ngTrim
下的angular文档中:

如果设置为假角度,则不会自动修剪输入。对于输入[type=password]控件,此参数将被忽略,因为它永远不会修剪输入。 (默认值:true)




我知道标题是
type=text
,但我查看了角度代码,该属性也适用于
type=search
。如果需要,我可以显示此代码。

谢谢,伙计。工作起来很有魅力!