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文件。
artistList(artistsongs: string) {
return artistsongs;
}
更改为:
artistList(artistsongs: any) {
return artistsongs;
}
据我了解,当您调用getSongsListArtist
时,它将返回一个数组对象或一个不仅是字符串的对象。您可以使用typeof()
检查this.httpClient.get(encodeURI(completeUrl))
返回哪种类型。