title: Angular 2 Custom Form Component: Provide a markTouched method
body: <p>I have a custom form component that implements ControlValueAccessor. This component has an internal property touched. </p>
  
  <pre><code>export class BmInputComponent implements ControlValueAccessor, Validator {
  
      private onTouchedCallback: () =&gt; {};
      private touched: boolean = false;
  
      registerOnTouched(fn: any) {
          this.onTouchedCallback = fn;
      }
  
      onBlur() {
          this.touched = true;
          this.onTouchedCallback();
      }
  }
  </code></pre>
  
  <p>I need to implement a method like </p>
  
  <pre><code>markTouched() {
      this.touched = true;
  }
  </code></pre>
  
  <p>That could be called by the user of the component when markAsTouched is executed in the formControl: <code>customInputControl.markAsTouched()</code></p>
  
  <p>I cannot find an angular-way to do this.</p>
  
  <p>@Edit:
  Tried to inject the NgControl:</p>
  
  <pre><code>@Component({
      selector: 'bm-input',
      templateUrl: './bm-input.component.html',
      encapsulation: ViewEncapsulation.None,
      providers: [
           {
              provide: NG_VALUE_ACCESSOR,
              useExisting: forwardRef(() =&gt; BmInputComponent),
              multi: true
          }
      ]
  })
  export class BmInputComponent implements ControlValueAccessor, Validator {
  
      private onTouchedCallback: () =&gt; {};
      private touched: boolean = false;
  
      constructor(@Self() @Optional() public _formControl: NgControl) {
          this._viewDate = new Date();
          if (this._formControl) {
              this._formControl.valueAccessor = this;
              this._formControl.statusChanges.subscribe(this.markTouched);
          }
      }
      registerOnTouched(fn: any) {
          this.onTouchedCallback = fn;
      }
  
      onBlur() {
          this.touched = true;
          this.onTouchedCallback();
      }
  
      markTouched() {
          if(this._formControl.touched)
              this.touched = true;
      }
  
  }
  </code></pre>
  
  <p>But I am getting <code>Cannot instantiate cyclic dependency! NgControl</code> when the component is invoked with a formControl.</p>