代码之家  ›  专栏  ›  技术社区  ›  Roxy'Pro

generic type subject<t>需要1个类型参数。-角度

  •  2
  • Roxy'Pro  · 技术社区  · 6 年前

    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();
      }
    }
    

    但现在我有一个错误:

    我不明白为什么?

    2 回复  |  直到 6 年前
        1
  •  4
  •   ggradnig    6 年前

    Subject

    private ngUnsubscribe: Subject<MyClass> = new Subject();
    
        2
  •  4
  •   Sachila Ranawaka    6 年前

    private ngUnsubscribe: Subject<any> = new Subject();