How to Get Index of Ngfor in Angular?

How to Get Index of Ngfor in Angular?

In this post we will give you information about How to Get Index of Ngfor in Angular?. Hear we will give you detail about How to Get Index of Ngfor in Angular?And how to use it also give you demo for it if it is necessary.

Hi All,

Now, let’s see post of angular get index in ngfor. This article goes in detailed on how to get index in angular ngfor. Here you will learn how to get index in ngfor angular. if you have question about get index in ngfor angular 9/8 then i will give simple example with solution.

we can easily get index from ngform in angular 6, angular 7, angular 8 and angular 9 application.

I will give you very simple example so you can easily understand how to get index key in ngfor angular.

You can get index from ngfor as bellow:

let category of categories;let indexOfElem=index;



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


selector: 'my-app',

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

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


export class AppComponent {

name = 'Angular';

categories = [

{id: 1, name: 'JQuery'},

{id: 2, name: 'Angular'},

{id: 3, name: 'Vue'},

{id: 4, name: 'React'}




Also see:Angular NgForm Example | NgForm Directive In Angular 9/8

<h1>How to get index of ngfor in Angular? -</h1>


<li *ngFor="let category of categories;let indexOfElem=index;">

ngFor index: {{indexOfElem}} value : {{}}



You can see belloe output:

I hope it can help you…

Hope this code and post will helped you for implement How to Get Index of Ngfor in Angular?. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs

For More Info See :: laravel And github

Leave a Comment

Your email address will not be published. Required fields are marked *

  +  2  =  4

We're accepting well-written guest posts and this is a great opportunity to collaborate : Contact US