2017-03-20 2 views
0

* ngForを使用してangular2を使用して動的表を作成していますが、データを表示できません。私は{{x [col]}}が正しいかどうか分かりません。Angular2動的列をループする

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

データフォーマットはどのように見えますか? –

+0

これを確認[**回答**](http://stackoverflow.com/questions/42633381/additional-column-created-using-angular2-and-bootstrap-4-table/42634574#42634574) – Aravind

答えて

0

内側ループの各行を走査する必要があります。 試してください:あなたは、単にXとcolsのを交換する必要が

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

。 exportListにはxのobject.soが含まれています。各ループに1つのオブジェクトがあります。オブジェクトを使用すると、各フィールドをフェッチできます。