简体   繁体   English

数组的两个对象上的角度过滤器

[英]Angular filter on two objects of an array

I have a filter on the JS side of angular.我在角度的 JS 侧有一个过滤器。

$filter('filter')($scope.ArrayofUserObjects, {Active: true, ID: passedInValue});

NOTE - my array is is an array of objects注意- 我的数组是一个对象数组

Let's say my array has 50 active users and 10 inactive users.假设我的阵列有 50 个活跃用户和 10 个非活跃用户。

The passedInValue is an inactive user's ID. passedInValue是非活动用户的 ID。 This filter at present will return 0 because each parameter of the array in essence is && together.这个过滤器目前会返回0因为数组的每个参数本质上都是&&一起的。

Question ---题 - -

I would like to alter this filter so the objects are ||我想改变这个过滤器,所以对象是|| together, which means the resulting filter would return 51在一起,这意味着生成的过滤器将返回51

Is this possible?这可能吗?

创建您自己的过滤器:

$filter('filter')($scope.ArrayofUserObjects, function(value){return value.Active || value.ID == passedInValue});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM