大家好,我正在尝试将所有评论放在数组中以在 *ngFor 上显示,但在订阅数据时出现 json 对象,因此无法连接。
这是我的代码
TS
this.http.post('http://' + this.ipAdress + ':3100/api/infitineComments/:id', { "page": this.page })
.map(res => res.json())
.subscribe(data => {
if (...) { //error part
}
else {
let d = [];
for(let i = 0; i< data.length; i++){
d.push(data[i])
}//I did this part because data was object in array type , also
//doesnt work
this.comments = this.comments.concat(d);
console.log("data: ", this.comments);
}
}, err => {
console.log("err: ", err);
});
Run Code Online (Sandbox Code Playgroud)
这是我的错误的小图片,所有列表都包括 id、comment、userId...

谢谢
| 归档时间: |
|
| 查看次数: |
20002 次 |
| 最近记录: |