Javascript 在AngularJS中按数字筛选数组
我想知道我是否可以在AngularJS中执行下面的代码。目标是按所有id>=搜索id筛选数组。我可以内联搜索,还是必须在javascript中作为自定义筛选器进行搜索Javascript 在AngularJS中按数字筛选数组,javascript,angularjs,Javascript,Angularjs,我想知道我是否可以在AngularJS中执行下面的代码。目标是按所有id>=搜索id筛选数组。我可以内联搜索,还是必须在javascript中作为自定义筛选器进行搜索 <div style="margin-top:5px;margin-left:30px;"> <div> <div>ID</div> <span class="glyphicon glyphicon-search"></spa
<div style="margin-top:5px;margin-left:30px;">
<div>
<div>ID</div>
<span class="glyphicon glyphicon-search"></span>
<input type="text" ng-model="listFoodItems.searchid" />
</div>
<table class="table table-responsive">
<thead>
<tr>
<th>ID</th>
<th>Description</th>
<th>Discount</th>
</tr>
</thead>
<tfoot></tfoot>
<tbody>
<tr ng-repeat="row in listFoodItems.fullitemdescs | filter: EntryId >= searchid">
<td>{{row.EntryId}}</td>
<td>{{row.ItemDesc}}</td>
<td>{{row.ItemDisc}}</td>
</tr>
</tbody>
</table>
</div>
身份证件
身份证件
描述
优惠
{{row.EntryId}
{{row.ItemDesc}}
{{row.ItemDisc}}
制作自定义过滤器的最佳方法如下:
HTML
下面是我的例子:制作自定义过滤器的最佳方法如下: HTML
下面是我的例子:首先,创建一个函数
$scope.lessThan = function(prop, val){
return function(item){
return item[prop] < val;
}
}
原始答案如下:
首先,创建一个函数
$scope.lessThan = function(prop, val){
return function(item){
return item[prop] < val;
}
}
原始答案如下:
您可以使用div(ng if=“row.EntryId>listfoodtems.searchid”)来包装tds。您可以使用div(ng if=“row.EntryId>listfoodtems.searchid”)来包装tds。您所拥有的与:
return item.id>=$scope.searchid代码>?因为我使用ng model=“searchid”绑定了输入,并且它存储在$scope.searchid中,所以您所拥有的与:return item.id>=$scope.searchid代码>?因为我使用ng model=“searchid”绑定了输入,它存储在$scope.searchid中
$scope.lessThan = function(prop, val){
return function(item){
return item[prop] < val;
}
}
<tr ng-repeat="row in listFoodItems.fullitemdescs | filter: lessThan('EntryId', searchid)">