如何设置 CSS class 名称来自 ngFor 中的 json 对象数组 | Angular 6
How to set a CSS class name comes from an array of json object inside ngFor | Angular 6
我有一个动态显示图标的循环,图标的位置由 style.css
上的 css
设置样式,但 类 名称实际上是 [= 的一个元素33=]对象。
问题 是如何使用 json 元素的值 style
来设置图标样式。
*ngFor 看起来像这样:
<div *ngFor="let count of counters; let i = index" class="{{count.style}} dispanserDiv ">
<span class="dispLabel"> {{count.name }}</span>
<img (click)="openStockModal(stockModal)" class="dispanser" src="../assets/icons/dispanserIcons/0.png">
</div>
我也试过 [ngClass] 但没有用,感谢任何帮助。
好吧,在我打开检查元素后,我将鼠标悬停在标签上,我在屏幕上发现了一条标题消息,其中的方向箭头超出了屏幕的高度,所以我更改了 margin-top
attr th图标再次出现。
但我很确定当我设置 class 名称而不使用 json 元素值时,它显示正常,但是当我使用 json 元素时图标出现在不同的位置,但我不知道为什么会这样。但终于成功了
我有一个动态显示图标的循环,图标的位置由 style.css
上的 css
设置样式,但 类 名称实际上是 [= 的一个元素33=]对象。
问题 是如何使用 json 元素的值 style
来设置图标样式。
*ngFor 看起来像这样:
<div *ngFor="let count of counters; let i = index" class="{{count.style}} dispanserDiv ">
<span class="dispLabel"> {{count.name }}</span>
<img (click)="openStockModal(stockModal)" class="dispanser" src="../assets/icons/dispanserIcons/0.png">
</div>
我也试过 [ngClass] 但没有用,感谢任何帮助。
好吧,在我打开检查元素后,我将鼠标悬停在标签上,我在屏幕上发现了一条标题消息,其中的方向箭头超出了屏幕的高度,所以我更改了 margin-top
attr th图标再次出现。
但我很确定当我设置 class 名称而不使用 json 元素值时,它显示正常,但是当我使用 json 元素时图标出现在不同的位置,但我不知道为什么会这样。但终于成功了