gpt4 book ai didi

javascript - 在 angularjs Controller 中过滤 Json 数据

转载 作者:行者123 更新时间:2023-11-30 12:03:33 25 4
gpt4 key购买 nike

我正在使用 angular js 创建网络应用程序。我有 json 对象数组。我需要状态为 active 和 pending 的数据。这是我的数组:

$scope.response =  staticRoutes : [
{'id':1,'name':'ABC 1','subnet':'SUB 101','gateway':'GATE 101','status':'Active'},
{'id':2,'name':'ABC 2','subnet':'SUB 102','gateway':'GATE 102','status':'In Active'},
{'id':3,'name':'ABC 1','subnet':'SUB 101','gateway':'GATE 101','status':'Active'},
{'id':4,'name':'ABC 2','subnet':'SUB 102','gateway':'GATE 102','status':'In Active'},
{'id':5,'name':'ABC 1','subnet':'SUB 101','gateway':'GATE 101','status':'Active'},
{'id':6,'name':'ABC 2','subnet':'SUB 102','gateway':'GATE 102','status':'In Active'},
{'id':7,'name':'ABC 1','subnet':'SUB 101','gateway':'GATE 101','status':'Active'},
{'id':8,'name':'ABC 2','subnet':'SUB 102','gateway':'GATE 102','status':'In Active'},
{'id':9,'name':'ABC 1','subnet':'SUB 101','gateway':'GATE 101','status':'Active'},
{'id':10,'name':'ABC 2','subnet':'SUB 102','gateway':'GATE 102','status':'In Active'},
{'id':11,'name':'ABC 1','subnet':'SUB 101','gateway':'GATE 101','status':'Active'},
{'id':12,'name':'ABC 2','subnet':'SUB 102','gateway':'GATE 102','status':'In Active'},
{'id':13,'name':'ABC 3','subnet':'SUB 103','gateway':'GATE 103','status':'Pending'}
]

最佳答案

试试这个:

var filterdata = [];
angular.forEach($scope.response,function(value,key){
if(value.status == "active" || value.status == "pending")
{
filterdata.push(value);

}
})
console.log(filterFlows)

关于javascript - 在 angularjs Controller 中过滤 Json 数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35985845/

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