el_pup_le
el_pup_le

Reputation: 12179

Setting element position in ngFor

How can I set an element's left position to an iteree's value in a loop?

<div *ngFor="let label of labels" style="left: {{label.position}};">
  {{label.label}}
</div>

I've tried the braces but that doesn't work.

Upvotes: 0

Views: 948

Answers (1)

Poul Kruijt
Poul Kruijt

Reputation: 71911

You can use the [style] binding:

<div *ngFor="let label of labels" [style.left.px]="label.position">
  {{label.label}}
</div>

Upvotes: 3

Related Questions