我想在剑道网格列中使用if条件。但这是行不通的。我想根据情况放置图像。有语法错误吗?
<kendo-grid-column field ="Scanned_STS" title="Status" width="20">
<ng-template kendoGridCellTemplate let-dataItem> "# if(Scanned_STS == 1) { # #= "<img src=''>" # # } else if (Scanned_STS == 0) { # #= "<img src=''>" # # }"</ng-template>
</kendo-grid-column>
答案 0 :(得分:0)
嗨,如果您使用的是棱角分贝,可以使用NgIf
import { Component } from '@angular/core';
import { sampleProducts } from './products';
@Component({
selector: 'my-app',
template: `
<kendo-grid [data]="gridData">
<kendo-grid-column field="ProductName">
<ng-template kendoGridCellTemplate let-dataItem let-rowIndex="rowIndex">
<strong>{{dataItem.ProductName}}</strong>
<img *ngIf='dataItem.Discontinued' src='' alt='Item Discontinued'/>
<img *ngIf='!dataItem.Discontinued' src='' alt='Item Continued'/>
</ng-template>
</kendo-grid-column>
</kendo-grid>
`
})
export class AppComponent {
public gridData: any[] = sampleProducts;
}