简体   繁体   English

通过Angular访问对象

[英]Object access via Angular

I want to acccess the fields category and specCategory. 我要访问字段类别和specCategory。 I applied *ngFor="let x of data" {{x._id.category}} but it is not working. 我应用了*ngFor="let x of data" {{x._id.category}}但是它不起作用。 Whats wrong with it? 它出什么问题了?

I am using aggregate functionality to group the categories. 我正在使用聚合功能对类别进行分组。

  $group: {
              _id: {
        category: "$category",
        specCategory: "$specCategory"
    },


                min: {$min: '$price'},
                max: {$max: 500},
               total:{$sum:1}
            }

Result: 结果:

[ { _id: { category: 'Wasser & Wind', specCategory: 'Surfen' }, min: 49, max: 500, total: 1 }, { _id: { category: 'Reisen', specCategory: 'Hotel' }, min: 49, max: 500, total: 1 } ]

I will need to access the category, specCategory and total value 我将需要访问类别,specCategory和总价值

you miss closing curly brackets. 您会错过大括号。

{ _id: { category: 'Reisen', specCategory: 'Hotel' },

should be 应该

{ _id: { category: 'Reisen', specCategory: 'Hotel' }},

I added plunker take a look on file: app/app.component.ts 我添加了punker来查看文件:app / app.component.ts

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM