简体   繁体   中英

How to get value from object angular using *ngFor?

JSON 图像

I have a json structure like the image above.

I just want to get the value from the key name .

I was do Like this :

<span *ngFor="let outlet of products.body | keyvalue">{{outlet.value}}</span>

but that way is to call all attributes, I only want to call attribute name. how do?

Sorry for bad grammar, any suggestion or answer will be appreciate. Thank you

If you only want to get the value of name key, there is no need to use *ngFor .

It's enough to put it directly as follows.

<span>{{ products?.body?.name }}</span>

Please bind

{{outlet.name}}

instead of {{outlet.value}}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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