滞留在作出基于或运算符逻辑
问题描述:
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
答
我建议使用为每个appliedJob调用的自定义过滤器函数。
<tr data-dir-paginate="item in appliedJob | filter: myCoolFilter">
和功能(看看docs)
$scope.myCoolFilter(value, index, array) {
// change here according to your logic
return $scope.filterText || $scope.Closed;
}
+0
但我该如何使用单选按钮中的单击事件? – Fawel
+0
由于'$ scope.filterText','$ scope.Closed'等改变,由于摘要循环,列表会自动更新。我假设你已经知道angularjs是如何工作的。 –
您使用此https://github.com/michaelbromley/angularUtils/tree/master/src/directives/pagination? –
是的。为什么?它与我想要的任何关系? – Fawel
帮助你的信息,以及试图知道在哪里可以找到API的人如果可能的话 –