I run ngFor and I need that some attribute inside the loop would change it's value by adding to it ngFor index. That's mean that each div that is created in ngFor will have uniq attribute value. Source :
<div class="class1" *ngFor="let item of items; let i= index">
<div class="card-header" role="tab" id="Id">
<h1>Hello</h1>
</div>
I want to bind id to get it's value: Id0 when index=0.
<div class="card-header" role="tab" [attr.id]="Id+'i'"> Doesn't work :(
3 solutions
<div class="card-header" role="tab" id="{{'Id'+i}}">
<div class="card-header" role="tab" [attr.id]="'Id'+i">
<div class="card-header" role="tab" [id]="'Id'+i">
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With