title: Angular unsubscribe from BehaviorSubject as Observable
body: <p>I create a <code>BehaviorSubject</code> in one of my services, and using it asObservable to subscribe to it later, but i need to unsubscribe after the controller is destroyed, how can i unsubscribe from it.</p>
  
  <p><strong>Services</strong></p>
  
  <pre><code>import { Observable, BehaviorSubject } from 'rxjs';
  
    private currentStepObject = new BehaviorSubject&lt;number&gt;(0);
    public currentStepObservable = this.currentStepObject.asObservable();
  
    constructor(
    ) { }
  
    public changecurrentStep(step: number): void {
      this.currentStepObject.next(step);
    }
  </code></pre>
  
  <p><strong>Controller</strong></p>
  
  <pre><code> import { ReaderService } from '../../../../services/reader/reader.service';
  
     constructor(
      private readerServices: ReaderService
     ) { }
  
     ngOnInit() {
       this.initDocumentData();
       this.readerServices.currentStepObservable
        .subscribe((step) =&gt; {
          this.currentStep = step;
        });
    }
  
    ngOnDestroy() {
    }
  </code></pre>