【发布时间】:2016-11-17 13:38:23
【问题描述】:
使用下面的代码,我可以在函数(响应)部分获得 console.log 响应,但在第二个 console.log 中却没有。使用 dzSearch 函数时,如何将该字符串从 DZ.api 中提取到子/任何变量中?
@Injectable()
export class DeezerService{
child:any;
constructor(){
new DZ.init({
appId : 'APPID',
channelUrl : 'https://localhost:4200/src/channel.html'
});
}
dzSearch(){
console.log('Testing dzSearch() init');
this.child = DZ.api('/album/12720342/tracks', function(response){
console.log(response.data[0].title)
return response.data[0].title;
});
console.log(this.child);
}
}
【问题讨论】:
标签: javascript angular deezer