2016-02-28 48 views
0

我有对象滤波器深嵌套属性返回空数组

var data = [{type:"A",parentPersonInfo:{id:1,fullname:'john smith'}},{type:"A",parentPersonInfo: {id:1,fullname:'jim smith'}},{type:"B",parentPersonInfo: {id:2,fullname:'jane smith'}}] 

我想使用lodash以提取其中type = A和id = 1

const testId = 1; 
_.filter(data,{'type':'A','data.parentPersonInfo.id':1}); 

但我得到的结果[阵列]

+0

是否有任何原因您没有创建MCVE? – Amit

+0

@Amit什么是MCVE – shresthaal

+1

http://stackoverflow.com/help/mcve – gearsdigital

回答

0

你能否检查下面的代码是否工作?

_.filter(data, {type: 'A', parentPersonInfo: {id:1}});