本文介绍了Filter在AngularJS中不等于的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个对象的数组,在客户端。 数组中的对象如下所示: { code:0, short_name :'a', type:1 } 使用类型=== 1 1 With type === 1
With type !== 1
我尝试过滤此数组为2个数组:
我做了这个:
$ 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:
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中不等于
发布评论