title: Why I am getting empty BehaviorSubject when accessing by url
body: <p>I have such problem I am making demonstrative web page that rely on the blog system in angular8.
  The issue occurs there:</p>
  
  <p>when I am using web link to route to the specified post unrolled then it works. But when I am using directly
  /post-details/3 it does not.</p>
  
  <p>posts.component.ts</p>
  
  <pre><code>  postDetailsClick(i){
      this.getSharedBodies.subject.next(this.body);  //setting BehaviorSubject
      this.getSharedTitles.subject.next(this.titles);
      this.router.navigate(['/post-details', i]);      
    }
  </code></pre>
  
  <p>posts.component.html:</p>
  
  <pre><code>&lt;mat-grid-list cols="3" rowHeight="150px"&gt;
      &lt;mat-grid-tile
          *ngFor="let post of showPosts; let i = index" 
          [colspan]="post.cols"
          [rowspan]="post.rows"
          [style.background]="post.color"&gt;
        {{post.text}}
       &lt;p&gt;&lt;button  (click)="postDetailsClick(i)" &gt;Try it&lt;/button&gt;&lt;/p&gt;    
      &lt;br&gt;    
      &lt;/mat-grid-tile&gt;
    &lt;/mat-grid-list&gt;
  </code></pre>
  
  <p>post-details.component.html</p>
  
  <pre><code>export class PostDetailsComponent implements OnInit {
    indexOfPost;
    titles;
    // bodies = [];
  
    subscription: Subscription;
    renderPost:boolean=false;
    constructor(private activatedRoute:ActivatedRoute,private getSharedTitles:ShareInfoTitleService,private getSharedBodies: ShareInfoBodyService) {}
  
  
    ngOnInit() {
      this.indexOfPost=this.activatedRoute.snapshot.paramMap.get("id");
      console.log(this.getSharedTitles.subject.asObservable());
  
    }
  }
  </code></pre>
  
  <p>line: console.log(this.getSharedTitles.subject.asObservable());
  returns null observable when accessed directly by the url. But when clicked button it works properly.</p>
  
  <pre><code>export class ShareInfoTitleService {
    subject = new BehaviorSubject&lt;any&gt;(null);
    constructor() { }
    sendMessage(message: any[]) {
      this.subject.next({ titles: message });
    }
    clearMessages() {
      this.subject.next(null);
    }
    getMessage(): Observable&lt;any&gt; {
      return this.subject.asObservable();
    }
  }
  </code></pre>