[英]*ngFor does not display data
我正在编写我的angular2应用程序。 我有从数据库中获取数据的服务,还有使用该服务显示获取数据的dashboard.component.html。
为myService:
detailedInfo(rownum:number){
const url='/project/users';
return this.http.get(`${url}/${rownum}`).pipe(map((data:any)=>data));
}
dashboard.component.ts:
resultDetails:any[]=[];
checkInformation(rownum:number) {
console.log("Details are called");
this.myService.detailedInfo(rownum).subscribe(
data=> {
console.log("we got:",data);
this.resultDetails=data;
console.log("length of details:"+this.resultDetails.length);
},
error => {
console.log("Error",error);
}
);
}
dashboard.component.html:
<i (click)="checkInformation(somenumber)"></i>
<table>
<tr *ngFor="let res of resultDetails">
<td >result
<p>any text</p>
</td>
<td>{{res.rownumber}}</td>
</tr>
</table>
console.log
打印正确的结果,但不显示任何内容。 我该如何解决这个问题? 提前致谢。
问题是错误的HTML
<i (click)="checkInformation(somenumber)"></i>
<table>
<tr *ngFor="let res of resultDetails">
<td >result
<p>any text</p>
</td>
<td>{{res.rownumber}}</td>
</tr>
</tr> <!-- this is extra tr remoe it
</table>
删除多余的tr
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.