title: Dynamic Attributes with AngularJS
body: <p>In some cases I need to apply different attributes to a node based on properties in my model.</p>
  
  <p>For example, in one case I need to add a 'required' tag and in another case not.  I've been using ng-if with different branches to accomplish this but the cases are getting out of hand quickly.  </p>
  
  <pre><code> &lt;div ng-if="model.required"&gt;
      &lt;input class="form-control"
             type="text"
             required 
             ng-model="model" /&gt;
   &lt;/div&gt;
   &lt;div ng-if="!model.required"&gt;
  
      // as different options arise,
      // i have more forks for each attribute combo
  
      &lt;input class="form-control"
             type="text"
             ng-model="model" /&gt;
   &lt;/div&gt;
  </code></pre>
  
  <p>Is there a better way to dynamic apply attributes to nodes?</p>