title: Subject vs BehaviorSubject in Angular
body: <p>I am passing data between 2 independent components using shared service. When I used a subject in my shared service, I could not see the subscribed data in html of the subscribed component but could see it in the console after subscribing.
  Whereas if I use Behaviorsubject, it worked fine.
  Can anyone explain me the reason for this.</p>
  <p>sharedservice.ts:</p>
  <pre><code>  //code with subject (not working)
    private msgStatistics = new Subject&lt;any&gt;();
        msgStatistics$ = this.msgStatistics.asObservable();
        msgStats(message) {
          this.msgStatistics.next(message)
        } 
  
  
      //code with BehaviorSubject (working)
      private msgStatistics = new BehaviorSubject&lt;Object&gt;(null);
        msgStatistics$ = this.msgStatistics.asObservable();
        msgStats(message) {
          this.msgStatistics.next(message)
        }
  </code></pre>
  <p>component2.ts:</p>
  <pre><code>this.shared_service.msgStatistics$.subscribe(res =&gt; {
          this.message = res
          console.log(this.message) 
  })
  </code></pre>
  <p>the above console is printing the value of message in both the cases but it is not rendering in html for subject.</p>