title: Accessing service from exported function in a module declaration in Angular 2+
body: <p>I have the following Module declaration:</p>
  
  <pre><code>import { ConnectionService } from './services/connection.service';
  import { NgModule } from '@angular/core';
  import { Http, RequestOptions } from '@angular/http';
  import { AuthHttp, AuthConfig } from 'angular2-jwt';
  
  export function authHttpServiceFactory(http: Http, options: RequestOptions) {
    return new AuthHttp(new AuthConfig({
      tokenName: 'token',
      tokenGetter: (() =&gt; sessionStorage.getItem('token'))
    }), http, options);
  }
  
  @NgModule({
    providers: [
      {
        provide: AuthHttp,
        useFactory: authHttpServiceFactory,
        deps: [Http, RequestOptions]
      }
    ],
  })
  
  export class AuthModule { }
  </code></pre>
  
  <p>and Service:</p>
  
  <pre><code>import { Injectable } from '@angular/core';
  
  @Injectable()
  export class ConnectionService {
      id;
  
      getToken() {
          return JSON.parse(sessionStorage.getItem('token'))[this.id];
      }
  }
  </code></pre>
  
  <p>I need to use the Services method "getToken" in the tokenGetter on the Modules exported function, but I can't make it work and Google hasn't answered my question (or I haven't been able to look properly).</p>