Hello Devs, 

In this tutorial, we will learn Angular Get Index in NgFor Example

In this section, we will see a simple example of get index in ngfor angular. you will learn how to get index in ngfor angular

Follow this step by step guide below. 



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'}




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



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

      ngFor index: {{indexOfElem}} value : {{category.name}} 



May this example help you.