title: Inject a service in a custom validator in Angular2
body: <p>I try to use a service in a custom validator to check if a username already exists.</p>
  
  <pre><code>import {Component} from 'angular2/core';
  import {
      Control,
      ControlGroup,
      FormBuilder
  } from "angular2/common";
  import {CharacterService} from "./character-service";
  
  @Component({
      selector: 'register-character-form',
      template: `
          &lt;h2 class="ui header"&gt;A new adventurer is coming...&lt;/h2&gt;
          &lt;form (ngSubmit)="register()" [ngFormModel]="characterForm" class="ui form"&gt;
              &lt;div class="field"&gt;
                  &lt;label&gt;Nom&lt;/label&gt;
                  &lt;input ngControl="name"&gt;
              &lt;/div&gt;
              &lt;button type="submit" class="ui button"&gt;Enter in the adventure&lt;/button&gt;
          &lt;/form&gt;
      `,
      providers: [CharacterService]
  })
  export class RegisterCharacterFormCmp {
      characterForm: ControlGroup;
      name: Control;
  
      constructor(private _characterService: CharacterService, fb: FormBuilder) {
          this.name = fb.control('', this.characterNameValidator);
  
          this.characterForm = fb.group({
              name: this.name
          });
      }
  
      register(): void {
          //TODO: To implement
      }
  
      // Not works, this binds the control
      characterNameValidator(control: Control) {
          return this._characterService.isCharacterNameAlreadyExists(control.value) ? {nameCharacterAlreadyExistsError: true} : null;
      }
  }
  </code></pre>
  
  <p>It doesn't work. In the characterNameValidator, 'this' references the control and not my class. The service is undefined. How can I use my service in the validator ?</p>
  
  <p>More globally, how can I pass arguments in a custom validator ?</p>