NetanelBasal
8/17/2018 - 7:33 AM

ngSubscribe-2.directive.ts

  @Input()
  set ngSubscribe(inputObservable: Observable<any>) {
    
    if (this.observable !== inputObservable) {
      this.observable = inputObservable;
      this.subscription && this.subscription.unsubscribe();
      
      this.subscription = this.observable.subscribe(value => {
        this.context.ngSubscribe = value;
        this.cdr.markForCheck();
      });
      
    }
  }