How to set dynamic id in angular2?
I have tried
<div class = "CirclePoint" *ngFor="#c of circles" id = "{{ 'Location' + c.id }}"></div>
this.circles = [
{ x: 50 , y: 50 ,id : "oyut1" },
{ x: 100 , y: 100 ,id : "oyut3" },
{ x: 150 , y: 150 ,id : "oyut2" }
];
but it does not work.
Try this:
Hopefully this will work for you. I searched StackOverflow and I found this answer.
For theid
attribute this might work as well (not tried myself yet)Inside the component tag instead of the usual
id="#c"
use[id]="#c"
. This also applies to dynamic class names. See example below: