2014-12-04 105 views
0
<li> 
    <p>By Member Status</p> 
     <p><label><input type="checkbox" ng-model="filter['top']"> top</label></p> 
     <p><label><input type="checkbox" ng-model="filter['low']"> low</label></p> 
       </li> 
<li> 
        <p>By ADMIN Status</p> 
        <select class="form-control" ng-init="selectedSearch = 'default'"> 
         <option value="default">Select Status</option> 
         <option value="A" ng-model="filter['a']">A</option> 
         <option value="B" ng-model="filter['b']">B</option> 
        </select> 
       </li> 

    <div class="complete-profile" ng-class="{active:show}" ng-repeat="mylist in mylist | filter:filterByCategory"></div> 

    $scope.filterByCategory = function (stat) { 
     return $scope.filter[stat.state] || noFilter($scope.filter); // checkbox 
    }; 
$scope.filterByCategory = function (stat) { 
     return $scope.filter[stat.drop] || noFilter($scope.filter); // dropdown 
    }; 

我需要應用兩個篩選器上的mylist,但不知何故一個篩選器工作的複選框或下拉都從來沒有工作。如何區分呼叫過濾器angularjs

回答

0

你應該更新你的過濾邏輯。 Code here

... 
$scope.filter = { 
    top: false, 
    low: false, 
    byAdminStatus: 'A' 
} 
... 
0

您聲明瞭$scope.filterByCategory兩次。因爲JavaScript variable names must be unique,第一個聲明將被第二個覆蓋。

我建議給每個過濾器自己有意義的名稱。然後,可以chain the filters together以產生所述複合過濾:

<div ng-repeat="item in mylist | filter:filterByState | filter:filterByDrop"> 

下面是使用上的ng-repeat多個過濾器的一個示例:http://jsfiddle.net/2671uggu/