title: Angularjs - Inserting directives dynamically to dom element
body: <p>I'm trying to set a directive to my inputs accordingly.</p>
  
  <p>So let's say I have this input:</p>
  
  <pre><code>&lt;input type="foo" id="myinput" maskvalue&gt; &lt;/input&gt;
  </code></pre>
  
  <p>This works fine on my app, the problem is when I try to insert "maskvalue" dynamically using the "setAttribute" it doesn't work, here's what I'm trying to do right now:</p>
  
  <pre><code>element = document.getElementById('myinput');
  if(element){
    element.setAttribute('maskvalue', "");
  }
  </code></pre>
  
  <p>This code will successfully insert my directive to the dom element, but will take no effect. It seems that is impossible to insert a custom directive to the dom when it was already loaded, am I wrong?</p>
  
  <p>But that's basically the question, how can I insert a directive dynamically to a dom element?</p>
  
  <p>Thanks</p>