Search
 
SCRIPT & CODE EXAMPLE
 

HTML

ngfor index

<ul>
    <li *ngFor="let item of items; let i = index" [attr.data-index]="i">
        {{item}}
    </li>
</ul>
Comment

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

ngfor index

<ul>
    <li *ngFor="let item of items; index as i">
        {{item}}
    </li>
</ul>
Comment

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-->
Comment

ngfor index

<ul>
    <li *ngFor="let item of items; let i = index" [attr.data-index]="i">
        {{item}}
        {{i}}
    </li>
</ul>
Comment

index in ng for

You have to use let to declare the value rather than #.

<ul>
    <li *ngFor="let item of items; let i = index" [attr.data-index]="i">
        {{item}}
    </li>
</ul>
Angular = 1
<ul>
    <li *ngFor="#item of items; #i = index" [attr.data-index]="i">
        {{item}}
    </li>
</ul>
Comment

PREVIOUS NEXT
Code Example
Html :: syntax for ngfor 
Html :: dont show suggestions in input hs 
Html :: add favicon to website html 
Html :: sms link 
Html :: fa fa copy icons 
Html :: video tag html 
Html :: footer ionic 
Html :: @keyup.enter vue 
Html :: como cambiar el color html 
Html :: calendar input 
Html :: how to disable password autofill in react 
Html :: ion-button outline 
Html :: how to right align a text button 
Html :: laravel murakkab old 
Html :: input without autocomplete 
Html :: vscode-jest intellisense not working 
Html :: restart remote computer cmd using ip address 
Html :: email template code 
Html :: pound symbol phone html 
Html :: html viewport 
Html :: auto year in html 
Html :: bootstrap 4 button with icon 
Html :: ayoaduwo 
Html :: coc allow comments in json 
Html :: how to create a search bar like google in html 
Html :: excel timestamp to date 
Html :: component in ejs 
Html :: input tag with data list 
Html :: blankspace html 
Html :: html lang 
ADD CONTENT
Topic
Content
Source link
Name
6+7 =