title: Angular 2 Global Constants Provider Injector Method
body: <p>I have a global constants like root directory that I want every component to have access to. In another stackoverflow question the answer was to create a constants class and import that to every component. </p>
  
  <p>Is there a way to bootstrap a constants class so that every component in the app has access to it without any additional importing?</p>
  
  <p>I have this so far but it is not working, how do I boostrap the constants class and then access then in my components?</p>
  
  <p><code>constants.ts</code></p>
  
  <pre><code>export class Constants{
    root_dir: string;
  
    constructor(){
        this.root_dir = 'http://google.com/'
      }
    }
  </code></pre>
  
  <p><code>main.ts</code></p>
  
  <pre><code>import {bootstrap} from 'angular2/platform/browser'
  import {Constants} from './constants'
  
  bootstrap([
    provide(Constants, {useClass: Constants})
  ]);
  </code></pre>
  
  <p><code>random.component.ts</code></p>
  
  <pre><code>import {Component, bind} from 'angular2/core';
  import {Injector} from 'angular2/core';
  
  @Component({
      selector: 'my-app',
      template: `{{test}}`
  })
  
  export class RandomComponent{
      test: string;
  
      constructor(){
          this.test = injector.get(Constants.root_dir);
      }
  }
  </code></pre>