Angular - how can I take the data from API call and use it to populate a table?

Discussão em 'Angular' iniciado por Bishibro, Abril 8, 2025.

  1. Bishibro

    Bishibro Guest

    I am trying to take the information received from API call and use it to fill the table. Also, why is this.movies a blank array when I try and set the value equal to the data.

    [​IMG]

    [​IMG]




    import { Component, OnInit } from '@angular/core';
    import { HttpClient, HttpHeaders } from '@angular/common/http';
    import { CinemaService } from './services/cinema.service';

    @Component({
    selector: 'app-root',
    templateUrl: './app.component.html',
    styleUrls: ['./app.component.css']
    })
    export class AppComponent{
    title = 'movie-app';

    data: any = [];
    constructor(private cinema: CinemaService)
    {
    this.cinema.getData().subscribe(movies=>{
    console.log(movies)
    this.data = movies;
    })

    this.display(this.data);
    }

    display(thing: any)
    {
    console.log(this.data);
    }

    }

    Continue reading...

Compartilhe esta Página