【发布时间】:2018-12-08 08:15:00
【问题描述】:
我正在从我的服务中获取数据,我对订阅后退订很重要感到不满,这就是我的做法:
export class RItemComponent implements OnInit {
apiPath = environment.apiUrl;
private ngUnsubscribe: Subject = new Subject();
constructor(private _sharedService: SharedService) { }
rItems: Product[];
ngOnInit() {
this._sharedService.
getReceiptItem().takeUntil(this.ngUnsubscribe).
subscribe(products => this.rItems = products);
}
ngOnDestroy() {
this.ngUnsubscribe.next();
this.ngUnsubscribe.complete();
}
}
但现在我收到一个错误:
Generic type Subject<T> requires 1 type argument(s). subscribe
我不明白为什么?
任何形式的帮助都会很棒,谢谢!
【问题讨论】:
标签: angular typescript rxjs angular-services