【发布时间】:2016-04-04 05:28:32
【问题描述】:
我有这个对象数组
var list = [{
"questionId": 1,
"correctChoiceIds": [],
"choiceId": 0,
"number": 1
}, {
"questionId": 1,
"correctChoiceIds": [1234, 4567],
"choiceId": 0,
"number": 2,
}, {
"questionId": 2,
"correctChoiceIds": [],
"choiceId": 0,
"number": 3
}];
//This filter gives me an array with list[0] and list[1]
var filterQuestion = $filter('filter')(list, { questionId: 1 }, true);
我想为他们的correctChoiceIds过滤所有具有空数组的人。
var filterNoCorrectChoice= $filter('filter')(list, { correctChoiceIds: [] }, true);
这是我想出的,但它根本没有给我任何东西。我不确定这是否是正确的方法,或者为什么它没有结果。
【问题讨论】:
标签: javascript arrays angularjs angular-filters