AngularJS Typeahead和$http请求限制



我试图限制Angular Bootstrap Typeahead在执行异步调用时返回的结果数量,但它根本不起作用。

<input type="text" ng-model="asyncSelected" 
placeholder="Locations loaded via $http" typeahead="address for address in getLocation($viewValue) | limitTo:3" 
typeahead-loading="loadingLocations" class="form-control">

我在Plunker示例中添加了limitTo:3来测试它,但它不起作用,有没有办法做到这一点,或者这是Typeahead中的一个错误?

plnkr

我认为typeahead过滤器不适用于异步调用。请参阅此线程:https://github.com/angular-ui/bootstrap/issues/993

它可能没有那么优雅,但您可以在获取函数中过滤结果。

最新更新