我是AngularJS的新手,我正尝试构建一个简单的Whiskey搜索应用程序。使用Angular可以轻松绑定输入元素和我的结果,但是结果会在用户键入时进行过滤。我不希望在用户按下Enter键之前进行过滤。
这是我用于输入搜索的代码:
<input type="text" class="form-control" placeholder="start typing and hit enter" ng-model="query">
这是我的结果:
<div class="col-lg-12" ng-controller="WhiskeyListCtrl">
<div class="row">
<div class="col-sm-3" ng-repeat="whiskey in whiskeys | filter:query">
<div class="whiskey-container">
<a href="#/whiskeys/{{whiskey.id}}"><img ng-src="{{whiskey.images[0]}}" height="200" width="200"/></a>
<whiskey-title></whiskey-title>
<whiskey-desc></whiskey-desc>
</div>
</div>
</div>
</div>
任何帮助将不胜感激!
最佳答案
您可以使用ngModelOptions
<input type="text" class="form-control" placeholder="start typing and hit enter" ng-model="query" ng-model-options="{updateOn : 'change blur'}">