如果querytext的长度等于2,我怎么能开始过滤?
我有这段代码,我不知道如何在querytext.length> = 2时开始过滤
<input type="search" ng-model="querytext">
<ul>
<li ng-repeat="value in filteredList | filter:querytext>{{value.Name}}</li>
</ul>
$scope.filteredList =[{Id:1,Name:"Soul"},{Id:2,Name:"Croft"}];
答案 0 :(得分:30)
将ng-minlength="2"
添加到<input>
元素。
<input type="search" ng-model="querytext" ng-minlength="2" />
<!-- ^^^^^^^^^^^^^^^^ -->
答案 1 :(得分:0)
正如@Daiwei所建议的,这就是我所做的:
<input type="search" ng-model="querytext" ng-minlength="2">
<ul>
<li ng-repeat="value in filteredList | filter:querytext>{{value.Name}}</li>
</ul>
它有效!谢谢!