Html – How to add dynamic index from ngFor to html attribute value

angularhtml

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 :(

Best Answer

Try:

<div class="card-header" role="tab" id="{{'Id'+i}}">