こんにちは私は* ngForで表示するにはすべてのコメントを配列に入れようとしていますが、購読データではjsonオブジェクトが来るので連結できません。ここ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配列を連結する文字列に変換しますか?意味がありません。 –