Angular 2: Subscribe once in MainComponent for all routes
<p>I have ProjectModule. Every page in this module requires the <code>projectService.projectData</code> property before loading.</p>

<p><strong>ProjectComponent</strong></p>

<pre><code>ngOnInit() {
this.af.auth.subscribe(auth =&gt; {
    this.route.params.forEach((params: Params) =&gt; {
    let name = params['name'];
    if (name) {
      this.projectService.getProject(name);
  }
  });
});
  }
</code></pre>

<p><strong>ProjectService</strong></p>

<pre><code>getProject(name) {
    //Friendly URL to ID
    this.af.database.object('/friendly_urls/' + name).take(1).subscribe((data) =&gt; {
      //ID to data
      this.af.database.object('/projects/' + data.$value).take(1).subscribe((projectData) =&gt; {
        this.projectData = projectData;
      });
    },
    error =&gt;  {
      console.log(error);
      /* TODO: Permission blocked page */
      this.router.navigate(['']);
    });
  }
</code></pre>

<p>I have to make <code>getProject(name)</code> method in each component to get the project data.</p>

<p>How I can make sure I get the <code>projectData</code> from the service before accessing any route?</p>

<p>Is it possible to achieve it without <code>subscribe</code> to service in each component <code>ngOnInit</code>?</p>