简体   繁体   English

如何在 html angular 组件中显示数组的属性值

[英]how to show the value of property of an array in html angular component

I need to show a property of an array this property has other propertys like: id, name, slug I need to show the name of genres我需要显示一个array的属性 这个属性还有其他属性,例如:id、name、slug 我需要显示流派的名称在此处输入图像描述

<div class="card-columns">
    <div class="card" *ngFor="let game of gameslist">
        <img class="card-img-top" [src]="game.background_image" alt="Card image cap">
        <div class="card-body">
            <h5 class="card-title">
                {{ game.name}}
            </h5>
            <p class="card-text">Platform Release on {{ game.platforms[1].platform}}</p>
            <p class="card-text">Release date {{ game.platforms[1].released_at}}</p>
            <p class="card-text" *ngFor="let game of game.genres">Genere {{ game.genres}}/p>
                <p class="card-text">This card has supporting text below as a natural lead-in to additional content.</p>
                <p class="card-text"><small class="text-muted">Last updated 3 mins ago</small></p>
        </div>
    </div>
</div>

How can I show the name of genres if genres is an array that can have varios items each one with a name property in angular 9?如果流派是一个数组,可以在 angular 9 中包含每个具有 name 属性的各种项目,我如何显示流派的名称?

I fixed the bug with <p class="card-text" *ngFor="let genres of game.genres">Genere {{ genres.name}}</p>我用<p class="card-text" *ngFor="let genres of game.genres">Genere {{ genres.name}}</p>修复了这个错误

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

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