How to set dynamic id in *ngFor?
<div class = "CirclePoint" *ngFor="let c of circles"
[attr.id]="'Location' + c.id">
</div>
<div class = "CirclePoint" *ngFor="let c of circles"
attr.id="Location{{c.id}}">
</div>
For the id
attribute this might work as well (not tried myself yet)
<div class = "CirclePoint" *ngFor="let c of circles"
[id]="'Location' + c.id">
</div>
This also will work:
<div class = "CirclePoint" *ngFor="let c of circles">
<div [id]="c.id"></div>
</div>
If you want to add a prefix, say "loc";
<div class = "CirclePoint" *ngFor="let c of circles">
<div [id]="'loc' + c.id"></div>
</div>
Using [] helps to add values dynamically.
Try this:
<div class = "CirclePoint" *ngFor="let c of circles">
<div id="location_{{c.id}}">write something which you want like c.x </div>
</div>`
Hopefully this will work for you. I searched StackOverflow and I found this answer.