Get value from each *ngFor ionic 4, ionic 5, ionic 6
To get the value from each item in an ngFor
loop in Ionic 4, Ionic 5, or Ionic 6, you can use the index
and item
variables provided by the ngFor
directive.
Here is an example of how you can access the value from each item in the loop:
<ion-list>
<ion-item *ngFor="let item of items; let i = index">
{{ item }}
</ion-item>
</ion-list>
In this example, items
is an array containing the values you want to iterate over. Inside the *ngFor
loop, item
represents the current value in the iteration, and i
represents the index of the current item.
You can access and use the value of each item within the {{ }}
interpolation syntax. In this case, {{ item }}
will display the value of each item in the list.
If you need to perform any operations or access specific properties of each item, you can do so within the loop using the item
variable.
This approach can be applied in Ionic 4, Ionic 5, and Ionic 6 to retrieve the value from each item in an *ngFor
loop.