title: Adding attributes to HTML element in an AngularJS Directive
body: <p>I am new to angular and am attempting to add validation to a directive based on attributes.  Here is how I use the directive:</p>
  
  <pre><code>&lt;div sc-textbox data-bind-to="fieldToBind" data-field-name="fieldName" data-required="someValue != 'Office'"&gt;&lt;/div&gt;
  </code></pre>
  
  <p>The data-required attribute may or may not be present.  The template for the directive is:</p>
  
  <pre><code>&lt;input id="{{fieldName}}" name="{{fieldName}}" type="text" data-ng-model="bindTo" /&gt;
  </code></pre>
  
  <p>When the data-required attribute is present I would like to add data-ng-required="{{required}}" to the input.  How would I go about doing this?</p>
  
  <p>The scope for the directive is:</p>
  
  <pre><code>scope: {
      'bindTo': '=',
      'fieldName': '@',
      'required': '='
  }
  </code></pre>
  
  <p>Any help is greatly appreciated.</p>