title: Injecting Service Providers in Angular 2.0
body: <p>In the AngularJS 2.0 Heroes tutorial explanation it states that if a child component includes a service in its @Component Providers list, then Angular will create a separate instance of that service specific to the child.  What I don't understand is what you would do if sometimes you wanted to use the child component independently, and other times within a parent component. This seems like a severe restriction.  I've just playing with Angular 2.0, so most likely I've misunderstood something.</p>
  
  <p>Here's the explanation from the Angular.io site from the Services section of the Heroes Tutorial.</p>
  
  <blockquote>
    <p>Appendix: Shadowing the parent's service</p>
    
    <p>We stated earlier that if we injected the parent AppComponent
    HeroService into the HeroDetailComponent, we must not add a providers
    array to the HeroDetailComponent metadata.</p>
    
    <p>Why? Because that tells Angular to create a new instance of the
    HeroService at the HeroDetailComponent level. The HeroDetailComponent
    doesn't want its own service instance; it wants its parent's service
    instance. Adding the providers array creates a new service instance
    that shadows the parent instance.</p>
    
    <p>Think carefully about where and when to register a provider.
    Understand the scope of that registration. Be careful not to create a
    new service instance at the wrong level.</p>
  </blockquote>
  
  <p><a href="https://angular.io/docs/ts/latest/tutorial/toh-pt4.html#!#shadow-provider" rel="nofollow">Here's the link</a> to the page this came from to put it in context.</p>