ItSolutionStuff.com

Angular NgFor Example | NgFor Directive In Angular

By Hardik Savani β€’ May 2, 2024
Angular

Hi All,

I am going to explain you example of angular ngfor example. you can understand a concept of how to use ngfor in angular 8. it's simple example of angular 9 ngfor tutorial. let’s discuss about angular ngfor directive example.

You can use ngFor directive in angular 6, angular 7, angular 8, angular 9, angular 10, angular 11, angular 12, angular 13, angular 14, angular 15, angular 16 and angular 17 application.

Angular provide set of pre define directive and in this tutorial i will give you simple example of *ngFor. ngFor allows us to build data presentation lists and tables in HTML template.

Let's see bellow example:

src/app/app.component.ts

import { Component } from '@angular/core';

@Component({

selector: 'my-app',

templateUrl: './app.component.html',

styleUrls: [ './app.component.css' ]

})

export class AppComponent {

students = [

{id: 1, name: 'Hardik', email: 'hardik@gmail.com'},

{id: 2, name: 'Vimal', email: 'vimal@gmail.com'},

{id: 3, name: 'Harshad', email: 'harshad@gmail.com'},

]

}

src/app/app.component.html

<h1>Angular ngFor Directive Example - ItSolutionstuff.com</h1>

<table>

<tr>

<th>ID</th>

<th>Name</th>

<th>Email</th>

</tr>

<tr *ngFor="let student of students">

<td>{{ student.id }}</td>

<td>{{ student.name }}</td>

<td>{{ student.email }}</td>

</tr>

</table>

You can see bellow layout:

I hope it can help you...

Tags: Angular
Hardik Savani

Hardik Savani

I'm a full-stack developer, entrepreneur, and founder of ItSolutionStuff.com. Passionate about PHP, Laravel, JavaScript, and helping developers grow.

πŸ“Ί Subscribe on YouTube

We Are Recommending You

β˜…

Angular NgModel Example | NgModel Directive In Angular

Read Now β†’
β˜…

Angular NgStyle Example | NgStyle Directive In Angular

Read Now β†’
β˜…

Angular NgClass Example | NgClass Directive In Angular

Read Now β†’
β˜…

Angular NgSwitch Example | NgSwitch Directive In Angular

Read Now β†’
β˜…

Angular NgIf Example | NgIf Directive In Angular

Read Now β†’
β˜…

Angular NgIf Else | Ng If Else in Angular Example

Read Now β†’
β˜…

Angular NgClass - How to Add Dynamic Class in Angular 10/9/8?

Read Now β†’