title: Angular 2: How to inject simple types into your service
body: <p>I have a basic service that has a single string parameter</p>
  
  <pre><code>import {Injectable} from 'angular2/core';
  @Injectable()
  export class MyService  {
      constructor(someValue: string) {
      }
  }
  </code></pre>
  
  <p>If I remove the string param from the constructor the service will inject fine but I can't seem to figure out how to get a simple string to get injected.</p>
  
  <p>I have defined a config to store application settings</p>
  
  <pre><code>import {OpaqueToken} from 'angular2/core';
  
  export let APP_CONFIG = new OpaqueToken('app.config');
  
  export interface Config {
  appSetting: string,
  
  }
  
  export const CONFIG: Config = {
  appSetting: "my application nsetting"
  };
  </code></pre>
  
  <p>I defined a factory for MyService</p>
  
  <pre><code>import {provide}     from 'angular2/core';
  import {MyService} from './my.service';
  import {Config, CONFIG}    from './app.config';
  
  
  let myServiceFactory = (config: Config) =&gt; {
  return new MyService(config.appSetting);
  }
  
  export let myServiceProvider =
  provide(MyService, {
      useFactory: myServiceFactory,
      deps: [CONFIG]
  });
  </code></pre>
  
  <p>in my bootstrapping I register the provider</p>
  
  <pre><code>import {bootstrap} from 'angular2/platform/browser';
  import {AppComponent} from './app.component';
  import {provide} from 'angular2/core';
  import {APP_CONFIG, CONFIG}    from './app.config';
  import {myServiceProvider} from './my.service.provider';
  
  bootstrap(AppComponent,
  [provide(APP_CONFIG, { useValue: CONFIG }),
   myServiceProvider   
  ]);
  </code></pre>
  
  <p>in my app component I try to inject myService </p>
  
  <pre><code>import {Component} from 'angular2/core';
  import {MyService} from './my.service';
  @Component({
  selector: 'my-app',
  template: '&lt;h1&gt;Angular 2 is running&lt;/h1&gt;'
  providers: [
      MyService
  ]
  })
  export class AppComponent {
  
  constructor(private _myService: MyService) {
  }
  }
  </code></pre>
  
  <p>the application never starts up and I get this error</p>
  
  <blockquote>
    <p>0x800a139e - JavaScript runtime error: Uncaught (in promise): No provider for String! (AppComponent -> MyService -> String)</p>
  </blockquote>