title: How to conditional set the id attribute of a HTML element with angular js?
body: <p>I want to set the id attribute of a HTML element conditionally.</p>
  
  <p>Simple way:</p>
  
  <pre><code>&lt;!--  expression = true --&gt;
  &lt;div ng-if="expression"&gt; 
    &lt;a href id="this-one"&gt;Anchor with id&lt;/a&gt;
  &lt;/div&gt;
  &lt;div ng-if="!expression"&gt;
    &lt;a href&gt;Anchor without id&lt;/a&gt;
  &lt;/div&gt;
  </code></pre>
  
  <blockquote>
  <pre><code>output-if-expression-true = &lt;a href id="this-one"&gt;Anchor with id&lt;/a&gt;
  
  output-if-expression-false= &lt;a href&gt;Anchor without id&lt;/a&gt;
  </code></pre>
  </blockquote>
  
  <p>Can I avoid this with something like a ternary operator ? for example ...</p>
  
  <pre><code>&lt;a href ng-attr-id="{{expresion ? 'this-one': ''}}"&gt;Anchor&lt;/a&gt;
  </code></pre>