Angular dynamic table using ngFor

Discussão em 'Angular' iniciado por Frank, Fevereiro 26, 2025.

  1. Frank

    Frank Guest

    I would like to know if it is possible to create a dynamic HTML table from JSON data. The amount of columns and headers should change according to the keys in the JSON. For example this JSON should create this table:

    {
    color: "green", code: "#JSH810"
    }

    ,
    {
    color: "red", code: "#HF59LD"
    }

    ...


    [​IMG]

    And this JSON should create this table:

    {
    id: "1", type: "bus", make: "VW", color: "white"
    }

    ,
    {
    id: "2", type: "taxi", make: "BMW", color: "blue"
    }

    ...


    [​IMG]

    This has to be 100% dynamic though, because I want to display hundreds of different JSON objects, so nothing should be hard coded in the HTML page.

    Continue reading...

Compartilhe esta Página