A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.geeksforgeeks.org/angular-js/angular10-ngfor-directive/ below:

Angular10 NgFor Directive - GeeksforGeeks

Angular10 NgFor Directive

Last Updated : 23 Jul, 2025

In this article, we are going to see what is NgFor in Angular 10 and how to use it.

NgFor is used as a structural directive that renders each element for the given collection each element can be displayed on the page.

Syntax:

<li *ngFor='condition'></li>

NgModule: Module used by NgForOf is:

 

Selectors:

Approach: 

Example 1:

app.component.ts
import { Component } from '@angular/core';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
})
export class AppComponent  {
  a=['gfg1', 'gfg2', 'gfg3', 'gfg4']
}
app.component.html
<ul>
  <li *ngFor='let i of a'> {{i}} </li>
</ul> 

Output:

Example 2:

app.component.ts
import { Component } from '@angular/core';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
})
export class AppComponent  {
  a=['gfg1', 'gfg2', 'gfg3', 'gfg4']
}
app.component.html
<ol>
    <li *ngFor='let i of a'> {{i}} </li>
</ol>

Output:

Reference: https://v17.angular.io/api/common/NgForOf



RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4