问题
I have a drop down menu which get populated from Nggrid Column. The dropdown is a separate control.
I want to filter the NG-grid based on the value selected from drop down value. How do I do this?
回答1:
you could add an ng-change to your select like this:
select(ng-model="search", ng-options="data in datas", ng-change='myfilter()')
and in your controller:
$scope.myfilter = function() {
$scope.datas = $filter('filter')($scope.datas, {data.YourField: $scope.search});
// or:
// $scope.datas = $scope.datas.filter(function(data) {
// return data.YourField == search || data.YourOther == search;
// }
};
来源:https://stackoverflow.com/questions/22528007/how-to-filter-the-ng-grid-by-dropdown-values