What is ngFor?
ngFor is a directive that is used for iteration on the collection of data. ngFor has inbuilt variables which help to detect Index, First, Last anFirst, Even items at runtime.
ngFor is used with any HTML element but mostly we use it in those elements which help to display the data repetitively.
ngFor Syntax 1
The following syntax is very simple and similar to ForEach loop in C# and VB.NET.
*ngFor =”let <single object/item> of <collection object>”
Example
*ngFor = “let member of memberlist”

ngFor Syntax 2
The following syntax is very simple and is also, similar to ForEach loop in C# and VB.NET.
*ngFor =”let <single object/item> of <collection object>; let <variable name> = index”
Example
*ngFor = “let member of memberlist; let srno = index”

Step by step event binding in Angular using Visual Studio Code.
Step by step Implementation Syntax Format 1
- Click on Node.js command prompt to proceed.

- Create a project folder named ”MemberAng” in the command prompt.

Now, change the directory to newly created directory/folder called “MemberAng”.
Now, we pass command to create an Angular project called “membersample”.
After pressing the Enter key on command, the below given output screen will display.
In the above screenshot, you can see the message in the green colour [ Project “membersample” successfully created].
- Now, switch to Visual Studio Code and open the following folder.

D:\Angular4\MemberAng\MemberSample
Open this folder in Visual Studio.
- After opening the folder in Visual Studio Code, next, you can directly this folder from the recently opened folder list.

- By default, our project will look like this in visual studio code as per the screenshot.
No file opened by default.
- Now, again switch to command prompt.
In command prompt, we pass the command to OPEN (EXECUTE) our project with following CLI command.
ng serve open [PRESS ENTER]
As you pressed enter key in console window, it generates the following screen and hint to see your project on browser.
In browser, just type - localhost:4200
- Open you browser (My browser is Mozilla Developer Edition) type: localhost:4200 in addressbar.














Join the conversation! Your thoughts help the community grow.