title: Dependency injection with optional parameter in Angular2
body: <p>I have multiple components which require the same dependency which requires a string for the constructor. How can I tell angular2 to use a specific instance of the type for DI?</p>
  
  <p>For example:</p>
  
  <p>ChatUsers.ts:</p>
  
  <pre><code>@Component({
      selector: "chat-users"
  })
  @View({
      directives: [],
      templateUrl: '/js/components/ChatUsers.html'
  })
  export class ChatUsers {
  
      constructor(public currentUser : User) {
      }
  }
  </code></pre>
  
  <p>and app.ts:</p>
  
  <pre><code>/// &lt;reference path="../libs/typings/tsd.d.ts" /&gt;
  
  import {Component, View, bootstrap} from 'angular2/angular2';
  
  import {User} from "User";
  
  // How to create a user, e.g. new User('John') and use it for DI?
  
  @Component({
      selector: 'chat-app'
  })
  @View({
      directives: [ ],
      template: `
        &lt;div&gt; Some text
        &lt;/div&gt;`
  })
  class ChatApp {
      constructor(public user: User) {
          // do something with user
      }
  
  
  }
  bootstrap(ChatApp, [ User ]);
  </code></pre>
  
  <p>User.ts</p>
  
  <pre><code>export class User {
      name: string;
      constructor(name: string) {
          this.name = name;
      }
  }
  </code></pre>
  
  <p>If run this code, the error is:</p>
  
  <blockquote>
    <p>Cannot resolve all parameters for User(?). Make sure they all have
    valid type or annotations.</p>
  </blockquote>
  
  <p>I'm using the most recent angular2 version: <code>2.0.0-alpha.44</code></p>