title: Conditional Angular Component Provider
body: <p>I have a component that depends on a service that may either be provided by its parent component or create a new instance of that service depending on a dynamic condition. </p>
  
  <p>The problem I have is that if I specify a provider, or even a service provider, I lose the parent instance of the service. Is it possible to get a handle on the parent instance?</p>
  
  <pre><code> providers: [ myserviceProvider]
  </code></pre>
  
  <p>pseudo code in myServiceProvider:</p>
  
  <pre><code>provide: MyService,
      useFactory: myServiceFactory,
      deps: [AuthorisationService]
  
  const myServiceFactory = (authorisationService: AuthorisationService) =&gt; {
    return authorisationService.isAuthorised() ? /** what goes here? *// : new MyService();
  };
  </code></pre>
  
  <p>In the /* what goes here? */  space I want to return the existing  instance of myservice which would be injected if I hadn't declared a provider</p>
  
  <p>edited for clarity:
  the parent instance wouldn't be the root instance of the service (it has its own provider as well which is just injecting using standard provider syntax)</p>