title: Angular 2+ get an Array of all FormControl elements
body: <p>I have a need to inspect each of the form controls (<code>input</code>, <code>textarea</code>, etc.) in a form to read which type of element they are. I have a vast number of forms, and want to automate setting of different (default) validators for each type of form element. I don't want to have to list out every possible formControlName somewhere to define what type they are, so thought I could just inspect the HTML for that instead.</p>
  
  <p>My thought was to either get them all using some query selector that returns all elements with formControlName present, or I could loop through the form names that should be present, and get each item with a query selector the tests the names against the formControlName attribute.</p>
  
  <p>So if I have a form that looks like:</p>
  
  <pre><code>&lt;form novalidate [formGroup]="formGroup"&gt;
  
    &lt;div class="row"&gt;
      &lt;div class="group-label"&gt;Street&lt;/div&gt;
      &lt;input type="text" class="form-control" formControlName="street"&gt;
      &lt;div class="group-label"&gt;City&lt;/div&gt;
      &lt;input type="text" class="form-control" formControlName="city"&gt;
      &lt;div class="group-label"&gt;State&lt;/div&gt;
      &lt;input type="text" class="form-control" formControlName="state"&gt;
      &lt;div class="group-label"&gt;Some Description&lt;/div&gt;
      &lt;div class="nested"&gt;
          &lt;textarea class="form-control" formControlName="description"&gt;&lt;/textarea&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  
  &lt;/form&gt;
  </code></pre>
  
  <p>And a FormGroup that looks like:</p>
  
  <pre><code>this.formGroup = this.formBuilder.group({
    street: [addr ? addr.street : ''],
    city: [addr ? addr.city : ''],
    state: [addr ? addr.state : ''],
    description: [addr.description ? addr.description : ''],
  });
  </code></pre>
  
  <p>I would think I should be able to loop through the group, and find a form element matching each of the keys, inspect its tag name, and set validators based on weather the element is a <code>textarea</code> or <code>input</code>.</p>
  
  <p>This is a waaay simplified example, because I'm automating building the formGroups in a separate class, but it should get the point across.</p>
  
  <p>What is the proper way to do something like this in Angular, if any, and are they security issues from doing such a thing?</p>