Here is a tutorial for the ngFor tutorial.
app.component.html file
<h1>My Custom Table</h1> <hr> <table id="users"> <tr> <th *ngFor = "let column of headers"> {{column}} </th> </tr> <tr *ngFor = "let row of rows"> <td *ngFor = "let column of headers"> {{row[column]}} </td> </tr> </table>
app.component.ts file
import { Component } from '@angular/core'; @Component({ selector: 'app-root', templateUrl: './app.component.html', styleUrls: ['./app.component.css'] }) export class AppComponent { headers = ["ID", "Name", "Age", "Gender", "Country"]; rows = [ { "ID" : "1", "Name" : "Rahul", "Age" : "21", "Gender" : "Male", "Country" : "India" }, { "ID" : "2", "Name" : "Ajay", "Age" : "25", "Gender" : "Male", "Country" : "India" }, { "ID" : "3", "Name" : "Vikram", "Age" : "31", "Gender" : "Male", "Country" : "Australia" }, { "ID" : "4", "Name" : "Riya", "Age" : "20", "Gender" : "Female", "Country" : "India" }, { "ID" : "5", "Name" : "John", "Age" : "23", "Gender" : "Male", "Country" : "USA" }, { "ID" : "6", "Name" : "Raman", "Age" : "27", "Gender" : "Male", "Country" : "India" }, { "ID" : "7", "Name" : "Mohan", "Age" : "39", "Gender" : "Male", "Country" : "India" }, { "ID" : "8", "Name" : "Shreya", "Age" : "21", "Gender" : "Female", "Country" : "India" } ] }
Click here for a complete post on how to create a table in Angular using ngFor