title: Moving from method to services angular
body: <p>I have a function which I use in my app.module.ts as given below</p>
  <pre><code>providers:[
    ...
    ,
    {
      provide: APP_INITIALIZER,
      useFactory: loadTranslation,
      deps: [TranslateService, Injector],
      multi: true
    }
    ,
    ...
  ]
  
  ...
  
  export function loadTranslation(translate: TranslateService, injector: Injector){
  return () =&gt; new Promise&lt;any&gt;((resolve: any) =&gt; {
   ...
   })
  }
  </code></pre>
  <p>My question is how to move loadTranslation method to a separate service and use it in providers with the deps?</p>
  <p>Update #1:</p>
  <p>Used as given below based on the answer</p>
  <pre><code>{
    provide: APP_INITIALIZER,
    useFactory: (translateService: TranslateInitializationService) =&gt; () =&gt; translateService.loadTranslation(),
    deps: [TranslateInitializationService,TranslateService,Injector],
    multi: true
  },
  </code></pre>
  <p>and in the service</p>
  <pre><code>@Injectable({providedIn: &quot;root&quot;})
  export class TranslateInitializationService {
  
      constructor(public translate: TranslateService, public injector: Injector) { }
  
      loadTranslation = () =&gt; {
          return () =&gt; new Promise&lt;any&gt;((resolve: any) =&gt; {...});
      }
  }
  </code></pre>
  <p>but getting this error</p>
  <p><code>ERROR TypeError: o.loadTranslation is not a function</code></p>