angularjs過濾器我有一個觀點:滯留在作出基於或運算符邏輯
<tr>
<td>
<label class="radio-inline">
<input type="radio" name="Active" checked ng-click="sort('false','false','false')">Active
<span class="label label-success">{{totalActive}}</span>
</label>
</td>
<td>
<label class="radio-inline">
<input type="radio" name="Active" ng-click="sort('true','','true')">Archieve
<span class="label label-warning">{{appliedJob.length-totalActive-totalClosed}}</span>
</label>
</td>
<td>
<label class="radio-inline">
<input type="radio" name="Active" ng-click="sort('','true','')">Closed
<span class="label label-warning">{{totalClosed}}</span>
</label>
</td>
</tr>
<tr data-dir-paginate="item in appliedJob|orderBy:'AppliedDate':true|filter:{HiredAnother:filterText, Closed:Closed,Withdraw:w}|itemsPerPage:5">
MY JS功能:
$scope.filterText = false;
$scope.Closed = false;
$scope.w = false;
$scope.sort = function (key,c,w) {
$scope.filterText = key;
$scope.Closed = c;
$scope.w = w;
}
什麼,我想的是,如果提款是假的,將繼續Archieve
(不管HiredAnother
是真是假)。但是在過濾器中,它僅在Archieve
列表中出現HiredAnother =true
和Withdraw=true
。 如何在ng-repeat過濾器中創建或(||)運算符?
清除我想:
Active-->HiredAnother=false,Closed=false, Withdraw=false
Archieve-->HiredAnother=true/false,Closed=false, Withdraw=false/true(HiredAnother and Withdraw- must be false at least one)
Closed-->HiredAnother=true/false,Closed=true, Withdraw=false/true
=================與預期結果更新過的============== ============
<tr>
<td>
<label class="radio-inline">
<input type="radio" name="Active" checked ng-click="sort('ac')">Active
<span class="label label-success">{{totalActive}}</span>
</label>
</td>
<td>
<label class="radio-inline">
<input type="radio" name="Active" ng-click="sort('ar')">Archieve
<span class="label label-warning">{{appliedJob.length-totalActive-totalClosed}}</span>
</label>
</td>
<td>
<label class="radio-inline">
<input type="radio" name="Active" ng-click="sort('cl')">Closed
<span class="label label-warning">{{totalClosed}}</span>
</label>
</td>
</tr>
<tr data-dir-paginate="item in appliedJob|orderBy:'AppliedDate':true|filter:myFilter|itemsPerPage:5">
//Filter based on radio button
$scope.myFilter = function (i) {
return i.HiredAnother == false && i.Withdraw == false && i.Closed == false; //Active
};
$scope.sort = function (term) {
if (term == 'ac') {
$scope.myFilter = function (i) {
return i.HiredAnother == false && i.Withdraw == false && i.Closed == false; //Active
};
}
else if (term == 'ar') {
$scope.myFilter = function (i) {
return i.HiredAnother == true || i.Withdraw == true && i.Closed == false; //Arcieve
};
}
else if (term == 'cl') {
$scope.myFilter = function (i) {
return i.Closed == true; //Arcieve
};
}
}
//Filter based on radio button END
您使用此https://github.com/michaelbromley/angularUtils/tree/master/src/directives/pagination? –
是的。爲什麼?它與我想要的任何關係? – Fawel
幫助你的信息,以及試圖知道在哪裏可以找到API的人如果可能的話 –