[英]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.