他のすべての呼び出しが正常に機能していても、this.albumDetailsが特定の行に対して未定義であるというエラーを以下の関数呼び出しで受け取りました。角2は定義されていません
エラーがある:例外TypeError:_this.albumDetailsエラーがおそらく項目はJSONの配列がどのような援助がおかげで理解される
オブジェクトであるthis.albumDetails.concat(アイテム)で発生未定義
あります。
export class AppComponent {
albums: any[];
albumDetails: any[];
searchAlbum(input: any){
this.show = true;
this.searchService.getAlbum(input).subscribe(data => {
this.albums = data;
for(var i = 0; i < 50; i++){
this.searchService.getDetails(this.albums[i].artist, this.albums[i].name, this.albums[i].mbid).subscribe(items => {
this.albumDetails = this.albumDetails.concat(items); //Error occuring here at this.albumDetails.concat(items)
console.log(this.albumDetails);
});
}
});
}
}
ここで 'this.albumDetails'はどこで初期化しますか? – echonax
searchAlbumが定義されているクラスの外で –