【发布时间】:2021-08-31 22:17:11
【问题描述】:
下面是我的组件方法
if (id !== undefined && id != null && id !== 0) {
this.dataService.getTransactionById(id).subscribe(
(tr: ITransactionResponse) => {
if (tr != null) {
this.transaction = tr;
}
else {
this.router.navigate(['/']);
}
});
已弃用:但它在我的 Angular 项目中显示为已弃用。请让我知道我可以改变这种方法吗?
编辑:
我已将方法更改为以下代码 (RXJS 6)
this.tranService.getTransactionById(id).subscribe({
next: (result: any) => {
this.transaction = result;
},
error: (error:any) => {
this.router.navigate(['/transaction/transaction-list']);
},
complete: () => {
//console.log('complete');
}
});
但仍显示已弃用
【问题讨论】:
标签: angular typescript rxjs