江戶川亂折騰
2022-08-27 09:37:31
如何將多 *ngIf 應(yīng)用于返回到表的數(shù)據(jù)?我需要根據(jù)多條件*ngIf控制列名,但我不知道使用了哪個(gè)標(biāo)簽以及在哪里:*ngIf="coln=repcon.fieldName && repcon.columnType=1" then display data as icon link on field onlineurl*ngIf="coln=repcon.fieldName && repcon.columnType=2" then make it as hidden field to field onlineurl我在angular 7應(yīng)用程序上工作,我顯示動(dòng)態(tài)數(shù)據(jù)沒(méi)有固定的標(biāo)題或內(nèi)容 <thead > <tr> <th *ngFor="let coln of headerCols"> {{coln}} </th> </tr> </thead> <tbody> <ng-container *ngFor="let repcon of ReportControl"> <ng-container *ngFor="let repdata of ReportData"> <tr *ngFor="let rep of reportdetailslist"> <td *ngFor="let coln of headerCols"> <span>{{rep[coln]}}</span> // i think here can applied multi ng if but which tag used . </td> </tr> </ng-container> </ng-container> </tbody>sample dataReportId onlineurl reportdate1222 localhost:5000/ 12-12-20181222 localhost:7000/ 12-01-20191222 localhost:9000/ 12-12-2020control reportreportid fieldname columntype1222 onlineurl 1
1 回答

幕布斯6054654
TA貢獻(xiàn)1876條經(jīng)驗(yàn) 獲得超7個(gè)贊
根據(jù)您的條件,您可以嵌套 *ngIf :
<td *ngFor="let coln of headerCols">
<div *ngIf="coln=repcon.fieldName">
<div *ngIf="repcon.columnType=1">data as icon link</div>
<div *ngIf="repcon.columnType=2">hidden field</div>
</div>
</td>
或者用 *ngSwitch :
<td *ngFor="let coln of headerCols">
<div *ngIf="coln=repcon.fieldName" [ngSwitch]="repcon.fieldName">
<div *ngSwitchCase="1">data as icon link</div>
<div *ngSwitchCase="2">hidden field</div>
</div>
</td>
添加回答
舉報(bào)
0/150
提交
取消