title: Creating custom form input in Angular
body: <p>I'm creating my own form builder in angular.
  I have html code:</p>
  
  <pre><code>&lt;form [formGroup]="formGroup"&gt;
      &lt;my-input-field
              [field]="{type:'text'}"
              [formControlName]="'first'"&gt;&lt;/my-input-field&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>I don't know how to in <code>MyInputFieldComponent</code> fetch parent's <code>formGroup</code> (I don't want to pass it as extra property. Less boilerplate is better).
  I can fetch <code>parentElement</code> itself, but how to get parent <code>component</code> to get it's <code>formGroup</code> ?</p>
  
  <pre><code>constructor(protected elementRef: ElementRef) {}
  
  ngOnInit() {
     console.log(this.elementRef.nativeElement.parentElement);
  }
  </code></pre>