title: Angular share data between components using service
body: <p>I'm trying to share data between components using service. 
  In <code>project</code> component there is an click event on button </p>
  
  <pre><code>&lt;button type="submit" (click)="newValue()" class="btn btn-warning btn-sm mt-2"&gt;Create task&lt;/button&gt;
  </code></pre>
  
  <p>which should emit a string value </p>
  
  <pre><code>newValue() {
      this.shareService.changeValues("Hello from project");
    }
  </code></pre>
  
  <p>In service I'm trying to get an <code>observable</code> on  <code>BehaviorSubject</code> </p>
  
  <pre><code> private selectedValue = new BehaviorSubject&lt;string&gt;("");
  
    currentValue = this.selectedValue.asObservable();
  </code></pre>
  
  <p><code>Task</code> component has subscription, but value isn't updated.</p>
  
  <p><a href="https://stackblitz.com/edit/angular-using-service" rel="nofollow noreferrer">stackblitz</a></p>