Javascript 使用“单击事件”下拉菜单过滤角度
我只是尝试使用下拉列表中的输入来过滤或搜索相关数据。要求是在下拉列表中选择一个选项,然后单击按钮,该按钮应使用angular将相应的数据过滤或填充到表格中。我尝试过我可以直接做这件事,但不是通过点击事件。请帮我找出解决这个问题的办法,因为我是一个新手。这是我的密码: 我的Html:Javascript 使用“单击事件”下拉菜单过滤角度,javascript,angularjs,Javascript,Angularjs,我只是尝试使用下拉列表中的输入来过滤或搜索相关数据。要求是在下拉列表中选择一个选项,然后单击按钮,该按钮应使用angular将相应的数据过滤或填充到表格中。我尝试过我可以直接做这件事,但不是通过点击事件。请帮我找出解决这个问题的办法,因为我是一个新手。这是我的密码: 我的Html: Filter: <select ng-model="filterItem.store" ng-options="item.name for item in filterOptions.st
Filter:
<select ng-model="filterItem.store" ng-options="item.name for item in filterOptions.stores">
</select>
<button >search</button>
<table>
<tr>
<th>Name</th>
<th>Price</th>
<th>Rating</th>
</tr>
<tr ng-repeat="item in data | filter:customFilter">
<td ng-click="">
{{item.name}}</td>
<td>{{item.price}}</td>
<td>{{item.rating}}</td>
</tr>
</table>
普鲁克:
您可以将逻辑移动到某个函数,然后单击按钮调用该函数
$scope.filter = function(){
$scope.filtereddata = [];
angular.forEach($scope.data,function(key,value){
if(key.rating === $scope.filterItem.store.rating)
$scope.filtereddata.push(key);
})
}
HTML
<button ng-click="filter()">search</button>
安古拉斯普朗克
过滤器:
搜索
排序:
所选筛选器下拉项:{{filteriem.store.name}
所选排序下拉项:{{sortItem.store.name}
-
名称:{{item.Name}价格:{{item.Price}}评级:{{item.Rating}
名称
价格
评级
{{item.name}
{{item.price}}
{{item.rating}
我对我的plunker进行了一点修改,我不想根据IPU单独提供排序选项或过滤器选项,但它必须对表格进行排序。你能就此@Sajeetharan提出一些建议吗?问题是什么?我更新了我的plunker多一点。。提前谢谢
<button ng-click="filter()">search</button>
<li data-ng-repeat="item in filtereddata | orderBy:'price':reverse ">
Name: {{item.name}} Price: {{item.price}} Rating: {{item.rating}}
</li>