我创建了一个动态离子卡片,我想在每个卡片中改变颜色,但我不知道怎么做。我有一个像这样的数组
+-------------------------------+
|DESART|COLORWEB|...............|
+------+--------+---------------+
|bla123|#057EEF |...............|
+------+--------+---------------+
|bla232|#F3FF05 |...............|
+------+--------+---------------+
|bla151|#05gg00 |...............|
+------+--------+---------------+
|bla276|#F30005 |...............|
+------+--------+---------------+
这是c
<ion-card class="coworker-card" *ngFor="let itemDotaz of this.MyApp.json_articoli">
<ion-card-header >
<ion-card-title>
<ion-button /*here i must change color*/>
<ion-icon name="brush-outline"></ion-icon>
</ion-button>
{{this.MyApp.DoData(itemDotaz.DESART)}} {{this.MyApp.DoData(itemDotaz.COLORWEB)}}
</ion-card-title>
</ion-card-header>
<ion-card-content>
sono preseni {{itemDotaz.QTAART}} articoli di tipo {{this.MyApp.DoData(itemDotaz.CODART)}}
</ion-card-content>
</ion-card>
</ion-content>
您可以使用ngStyle
实现如下操作:
<ion-button [ngStyle]="{'color': itemDotaz.COLORWEB}">
<ion-icon name="brush-outline"></ion-icon>
</ion-button>