我想访问字段类别和specCategory。我申请了*ngFor="let x of data" {{x._id.category}}
,但它不起作用。它出什么问题了?通过Angular访问对象
我正在使用聚合功能来对这些类别进行分组。
$group: {
_id: {
category: "$category",
specCategory: "$specCategory"
},
min: {$min: '$price'},
max: {$max: 500},
total:{$sum:1}
}
结果:
[ { _id: { category: 'Wasser & Wind', specCategory: 'Surfen' }, min: 49, max: 500, total: 1 }, { _id: { category: 'Reisen', specCategory: 'Hotel' }, min: 49, max: 500, total: 1 } ]
我将需要访问类别,specCategory和总价值
那是因为你的对象不是一个数组。 Angular2不支持迭代遍历映射,只能遍历数组 – devqon