gpt4 book ai didi

arrays - AngularJS 中过滤不等于

转载 作者:行者123 更新时间:2023-12-02 11:19:54 25 4
gpt4 key购买 nike

我在客户端有一个对象数组。数组中的对象如下所示:

{
code: 0,
short_name: 'a',
type: 1
}

我尝试将此数组过滤为 2 个数组:

  1. 类型 === 1
  2. 类型为 !== 1

我这样做了:

$scope.array1 = $filter('filter')(data, {type: 1}, true);
$scope.array1 = $filter('filter')(data, {type: !1});

但是不等于不起作用...我能做什么?

谢谢!

最佳答案

同样,如果您只是要过滤,请使用 native method相反:

$scope.array1 = data.filter(x => x.type === 1);
$scope.array2 = data.filter(x => x.type !== 1);

关于arrays - AngularJS 中过滤不等于,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36418005/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com