簡體   English   中英

Angular2在動態列中循環

[英]Angular2 Looping through dynamic columns

我正在使用* ngFor使用angular2構建動態表,如下所示,但是我看不到數據。 我不確定{{x [col]}}是否正確,知道嗎?

<tr *ngFor="let x of exportList">
     <td *ngFor="let col of cols">
        {{x[col]}}
     </td>                      
 </tr>

您需要遍歷內循環中的每一行。 嘗試:

<tr *ngFor="let rows of exportList">
     <td *ngFor="let col of rows">
        {{col}}
     </td>                      
 </tr>
<tr *ngFor="let x of exportList">
     <td *ngFor="let col of x">
        {{col}}
     </td>                      
 </tr>

您只需要用x替換cols。 exportList包含對象的數量。因此,在x中,每個循環中將獲得一個對象。使用object可以獲取每個字段。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM