我正在尝试插入数据的表格和显示在我的页面,但我不知道如何插入数据和如何让数据显示在table.If中,任何人都知道,请帮助。
db.maintable.insert(
{
"id":"1",
"orderno":"19345",
"name" : "tutorialspoint",
"startedate":"21/04/2018",
"enddate":"28/12/2018"
},
{
"id":"2",
"orderno":"12945",
"name" : "tutorialspoint",
"startedate":"01/12/2018",
"enddate":"21/02/2018"
},
{
"id":"3",
"orderno":"12325",
"name" : "tutorialspoint",
"startedate":"21/22/2018",
"enddate":"24/12/2018"
}
)data.service.ts:
getTable() {
return this._http.get("/api/maintable")
.map(result => this.result = result.json().data);
}app.component.ts:
this._dataService.getUsers().subscribe(res => this.users = res);app.component.html:
<table>
<thead>
<th>Id</th>
<th>Order noo</th>
<th>Name</th>
<th>Start Date</th>
<th>End Date</th>
</thead>
<tbody>
<tr *ngFor="let getdata of maintable">
<td>{{ getdata.id }}</td>
<td>{{ getdata.orderno }}</td>
<td>{{ getdata.name }}</td>
<td>{{ getdata.startdate }}</td>
<td>{{ getdata.enddate }}</td>
</tr>
</tbody>
</table>发布于 2020-05-02 23:54:43
您在循环中犯了错误,使用result代替了maintable
<tr *ngFor="let getdata of maintable">https://stackoverflow.com/questions/61561984
复制相似问题