Filter在AngularJS中不等于

编程入门 行业动态 更新时间:2024-10-22 19:24:03
本文介绍了Filter在AngularJS中不等于的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我有一个对象的数组,在客户端。 数组中的对象如下所示:

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

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

  • 使用类型=== 1
  • 1
  • 我做了这个:

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

    但是不等于没有工作...我能做什么?

    谢谢!

    解决方案

    同样,如果您只是要 filter ,使用 $ $ p $ $ scope.array1 = data.filter(function(x){return(nofollow)> native method ) x.type === 1;}); $ scope.array2 = data.filter(function(x){return x.type!== 1;});

    在ES2015中

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

    I have a array of objects, in client side. The object in array look like this:

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

    I try to filter this array to 2 arrays:

  • With type === 1
  • With type !== 1
  • I did this:

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

    But the not-equal didn't work... what can I do?

    Thank you!

    解决方案

    Again, if you are just going to filter, use the native method instead:

    $scope.array1 = data.filter(function(x) { return x.type === 1; }); $scope.array2 = data.filter(function(x) { return x.type !== 1; });

    In ES2015

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

    更多推荐

    Filter在AngularJS中不等于

    本文发布于:2023-11-15 21:37:07,感谢您对本站的认可!
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:中不   Filter   AngularJS

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!