[英]Why using the data and error on the subscribe/observable like this is now deprecated in angular?
為什么不推薦使用此代碼? 正確的形式如何?
getPeopleFunction() {
this.peopleService.getPeopleService().subscribe(
(data) => {
console.log(data);
},
(error) => {
console.log(error);
}
);
}
您現在應該使用這種格式:
this.peopleService.getPeopleService().subscribe({
next: (v) => console.log(v),
error: (e) => console.error(e),
complete: () => console.info('complete')
})
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.