artistSelected(item: any) {
console.log(item.artist);
this.songsServices.getSongsListArtist(item.artist).subscribe(
result => {
this.songsServices.artistList = result;
this.route.navigate(['./artistsongs']);
},
error => {
console.log('There is an error');
}
);
}
Service
getSongsListArtist(album: string) {
const completeUrl = `${environment.API_URL}?album=${album}`;
return this.httpClient.get(encodeURI(completeUrl));
}
artistList(artistsongs: string) {
return artistsongs;
}
我正面临一个错误。请为我介绍如何使用服务将对象从一个ts文件传递到另一个ts文件。
答案 0 :(得分:0)
artistList(artistsongs: string) {
return artistsongs;
}
更改为:
artistList(artistsongs: any) {
return artistsongs;
}
据我了解,当您调用getSongsListArtist
时,它将返回一个数组对象或一个不仅是字符串的对象。您可以使用typeof()
来检查this.httpClient.get(encodeURI(completeUrl))
返回哪种类型。