Horje
ngfor with index Code Example
ngfor with index
<ul>
    <li *ngFor="let item of items; let i = index" [attr.data-index]="i">
        {{item}}
    </li>
</ul>
how to get index for ngfor
*ngFor="let item of items; index as i;" 
// OR
*ngFor="let item of items; let i = index;"
// i will be the index, starting from 0 
// and you can show it in the string interpolation with {{ i }}
ngfor index
<ul>
  <li *ngFor="let food of menu; index as i">
      {{ index }},{{ food }}
  </li>
</ul>
<!-- index starts from 0 
This gives an undordered list of food items in a menu, with the first item as 0-->
ngfor index
<ul>
    <li *ngFor="let item of items; index as i">
        {{item}}
    </li>
</ul>
ngfor

      <li *ngFor="let item of items; index as i; trackBy: trackByFn">...</li>
    
Source: angular.io
ngfor index
<ul>
    <li *ngFor="let item of items; let i = index" [attr.data-index]="i">
        {{item}}
        {{i}}
    </li>
</ul>




Html

Related
make websites all-deivce compatible Code Example make websites all-deivce compatible Code Example
visualizador de pdf html5 Code Example visualizador de pdf html5 Code Example
ver pdf en html Code Example ver pdf en html Code Example
abrir pdf con html Code Example abrir pdf con html Code Example
target blank rel Code Example target blank rel Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
10