我已经使用名为 Orderline 的 Angular 接口处理了我的 BE 对象,并将它们放入名为“orderlines”的数组中。如果“change_color”属性为真(它是一个布尔字段),我想在绿色背景上显示“orderline.ct_no”。
组件:
public displayOrderlines() {
this.service.getOrderLines().subscribe((response : Orderline[]) => {
this.orderlines = response;
})
}
在 .html 中,我试过这个,但它抛出了一个大错误,有什么想法吗?
<ng-container *ngFor="let orderline of orderlines">
<div class="row" >
<div [style.backgroundColor]="{{ orderline.color_change }} ? 'green' :
'white' "
class="container">
<div class="column">
<p class="value" >{{ orderline.ct_no }}</p>
</div>
</div>
</ng-container>
<div [style.backgroundColor]="orderline.color_change ? 'green' : 'white'" class="container">
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句