Arrays *ngFor不显示数据
我正在写我的angular2申请表。 我有一个从数据库获取数据的服务和dashboard.component.html,它使用该服务显示获取的数据 我的服务:Arrays *ngFor不显示数据,arrays,angular,typescript,Arrays,Angular,Typescript,我正在写我的angular2申请表。 我有一个从数据库获取数据的服务和dashboard.component.html,它使用该服务显示获取的数据 我的服务: detailedInfo(rownum:number){ const url='/project/users'; return this.http.get(`${url}/${rownum}`).pipe(map((data:any)=>data)); } dashboard.component.ts: resul
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>
结果
任何文本
{{res.rownumber}}
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>
结果
任何文本
{{res.rownumber}}
请添加数据看起来像什么console.log(“我们得到:”,数据)代码>output@mahval正确打印数组中的数据我想我们是在问响应是什么样子,显示JSON。你可以对你的问题进行编辑如果它是一个对象,你可以像这样使用keyvalue管道{{{data | json}}我认为这是问题中的一个输入错误,并对它进行了编辑!除息的