1
我想從數組呈現數據到HTML表格。這裏是我的模型:如何渲染ng-container Angular 2中數組的數據?
export class Section {
public id :number;
public name: string;
constructor(id: number, theName: string) {
this.id = id;
this.name = theName;
}
}
我導入並在組件填充:
import { Section } from "../models/registerSection.model";
數組聲明:
sectionList: Array<Section>;
陣列填充構造:
this.sectionList = [new Section(1, "A"),
new Section(2, "B*"),
new Section(3, "C"),
new Section(4, "D")];
這就是我想要的der數據模板:
<ng-container *ngFor='let data of Section'>
<tr>
<td colspan="7">{{data.name}}</td>
</tr>
</ng-container>
但是表格是空的。在DOM中,我看到以下內容:
<!--template bindings={
"ng-reflect-ng-for-of": null
}-->
我在做什麼錯了?在調試中,我可以看到該數組包含數據。
是的!謝謝....我沒有注意到。我糾結於研究角... – Seva