title: Dynamically adding required to input in template driven angular 2 form
body: <p><strong>Template driven approach:</strong> Dynamically adding required attribute to input filed in angular 2 form. But the angular form validation(form.valid) not recognizing the dynamically added required field. </p>
  
  <pre><code> &lt;input type="text"  [(ngModel)]="coumnName" name="coumnName" &gt;
  </code></pre>
  
  <p>Adding dynamically required:</p>
  
  <pre><code>document.getElementsByName(columnName)[0].setAttribute('required', '');
  </code></pre>