你好家伙我试图把所有的注释在数组中显示在* ngFor但订阅数据来自json对象,所以它不能concat。Concat不是函数
这里是我的代码
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);
});
我的错误,这里的小图片,所有列表涵盖ID,评论,用户id ...
谢谢
你试过用String(this.comments).concat(d) –
'this.comments'是否已经初始化? –
@SandipPatel转换为字符串连接数组?没有意义。 –