title: Adding id attribute to FormControl element or parent angular 7
body: <p>I'm trying to add an id attribute to the first invalid form control on form submission using angular reactive forms.</p>
  
  <p>Here is what i currently have in my component:</p>
  
  <pre><code>  onSubmit() {
      if (this.form.invalid) {
        this.scrollToError();
      } else {
        this.submitted.emit(this.form.value);
      }
    }
  
  
    private scrollToError() {
      for (const prop in this.form.controls) {
        if (this.form.controls[prop].errors) {
          const control = this.form.get(prop);
          if (control.invalid) {
            control.parent.setAttribute('id', 'error') &lt;=== Here is the issue
            console.log(control);
            break;
          }
        }
      }
    }
  </code></pre>
  
  <p>How can I get the element itself and add the id attribute?</p>
  
  <p>Thanks</p>