title: Global provider configurable once
body: <p>I am trying to make a config service that can be given an environment value which it then uses to spit back appropriate config values.</p>
  
  <p>Something like this </p>
  
  <pre><code>import { Injectable } from '@angular/core';
  
  @Injectable()
  export class ConfigService {
  private env: string;    
  
  SetEnv(value: string) {
      this.env = value;
  }
  
  Get() {
      let rtrn;
  
      if (this.env == "DEV") {
          rtrn = {
              api: "http://localhost:60517/api/"
          }
      }
      else if (this.env == "TEST") {
          rtrn = {
              api: "http://test:60517/api/"
          }
      }
      else { }
  
      return (rtrn);
  }
  }
  </code></pre>
  
  <p>Followed by this in <code>app.module.ts</code></p>
  
  <pre><code>providers: [
      ConfigService.SetEnv("DEV"),
      ....
  ]
  </code></pre>
  
  <p>And then used on the following manner after being injected into a component
  <code>ConfigService.Get().api</code></p>
  
  <p>The above example throws an error: <code>app.module.ts:64 Uncaught TypeError: __WEBPACK_IMPORTED_MODULE_12__services_config_config_service__.a.SetEnv is not a function</code></p>
  
  <p>Something along those lines...but I welcome other suggestions to accomplish this.</p>