This tutorial will give you example of angular 10 display json data in table. you can understand a concept of how to display data in angular 10. this example will help you angular 10 show data in table. i explained simply about how to show data in angular 10. Alright, let’s dive into the steps.
Sometime we need to display our data in table format for front end. we will use ngfor directive for display data in table. we will also use bootstrap for displaying data in angular application.
Let’s see simple following step to done simple example that will help you to displaying data in angular app.
Create New App
If you are doing example from scratch then You can easily create your angular app using bellow command:
ng new my-app
updated Ts File
In this file we will create students object array using Student interface. so let’s see bellow file code.
src/app/app.component.ts
import { Component } from '@angular/core';
interface Student {
id: Number;
name: String;
email: String;
gender: String;
}
@Component({
selector: 'my-app',
templateUrl: './app.component.html',
styleUrls: [ './app.component.css' ]
})
export class AppComponent {
name = 'Angular';
students: Student[] = [
{
id: 1,
name: "Hardik",
email: "hardik@gmail.com",
gender: "male"
},
{
id: 2,
name: "Paresh",
email: "Paresh@gmail.com",
gender: "male"
},
{
id: 3,
name: "Kiran",
email: "kiran@gmail.com",
gender: "female"
},
{
id: 4,
name: "Mahesh",
email: "mahesh@gmail.com",
gender: "male"
},
{
id: 5,
name: "Karan",
email: "karan@gmail.com",
gender: "male"
},
]
}
#angular #javascript #web-development #developer