【问题标题】:Setting element position in ngFor在 ngFor 中设置元素位置
【发布时间】:2017-12-05 03:54:48
【问题描述】:

如何在循环中将元素的左侧位置设置为 iteree 的值?

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

我试过大括号,但没有用。

【问题讨论】:

标签: angular


【解决方案1】:

您可以使用[style] 绑定:

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

【讨论】:

猜你喜欢
  • 1970-01-01
  • 2018-11-29
  • 2016-09-28
  • 2020-01-01
  • 2022-09-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多