1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

How to display a list of objects contained in an object

Discussão em 'Angular' iniciado por Bart Schelkens, Setembro 24, 2024.

  1. I have an object:

    export interface Album {
    id: number;
    title: string;
    remarks: string;
    artist: Artist;
    albumType: AlbumType;
    songs: Song[];
    }


    I can display an Album. This works without a problem.

    Now I want to display the songs contained on the album. How can I do that?

    I tried this:

    <tr *ngFor="let dataItem of {{album?.song}}">
    <td style="display:none;">{{dataItem.id}}</td>
    <td>{{dataItem.title}}</td>
    <td>{{dataItem.duration}}</td>
    <td>{{dataItem.remarks}}</td>
    </tr>


    But that doesn't work. I'm getting this error:

    NG5002: Parser Error: Unexpected token {, expected identifier, keyword, or string at column 18 in [let dataItem of {{album?.songs}}] in C:/Users/BSEBV60/source/repos/MusicAndBooksApplication/musicandbooksapplication.client/src/app/music/music-details/music-details.component.html@37:10


    Can anyone help?

    Continue reading...

Compartilhe esta Página