title: How to use service inside another?
body: <p>I have service that performs requests to server:</p>
  
  <pre><code>export class ExportDictionaryApiService {
    constructor(private http: HttpClient) {}
    public perform(): Observable&lt;any&gt; {}
  }
  </code></pre>
  
  <p>There is another class factory:</p>
  
  <pre><code>export class ExportFactory {
    public static createConcreteExcel(type: string) {
      switch (type) {
        case EReferenciesTypes.DictionaryType:
          return new ExportDictionary();
      }
    }
  }
  </code></pre>
  
  <p>And concrete class that is returned by factory:</p>
  
  <pre><code>export class ExportDictionary implements IExport {
    export(parameters: any) {
       this.apiService
        .perform().subscribe((response: IResponseDict) =&gt; {});
    }
  }
  </code></pre>
  
  <p><strong>Using is:</strong></p>
  
  <pre><code>ExportFactory.createConcreteExcel('full').export([...parameters]);
  </code></pre>
  
  <p><strong>Problem is:</strong></p>
  
  <p>Concrete class should use concrete <code>apiService</code>, and now there is no ready object <code>apiService</code> inside <code>class ExportDictionary</code></p>
  
  <p>How to pass it in concrete class?
  I need return ready instance with all dependencies inside!</p>
  
  <p>Certainly I can inject ready object in method:</p>
  
  <pre><code>ExportFactory.createConcreteExcel('full').export([...parameters], injectedApiService);
  </code></pre>
  
  <p>But I dont know <code>injctedApiService</code> uNtil I dont create concrete Factory.</p>
  
  <p>Also I can not create object inside:</p>
  
  <pre><code>export(parameters: any) {
         new ExportDictionaryApiService()
            .perform().subscribe((response: IResponseDict) =&gt; {});
   }
  </code></pre>
  
  <p>Because <code>ExportDictionaryApiService</code> requires dependency <code>HttpClient</code></p>