title: How to remove attribute directives from element directive in AngularJS?
body: <p>I have an element directive and an attribute directive:</p>
  
  <pre><code>&lt;my-element my-attribute="value"&gt;&lt;/my-element&gt;
  </code></pre>
  
  <p>my-attribute is a directive which require ngModel:</p>
  
  <pre><code>    app.directive('myAttribute', [
      function() {
  
          var definition = {
              restrict: 'A',
              require: 'ngModel',
              link: function ($scope, $element, $attrs, ctrl) {...}
  }
  return definition;
  </code></pre>
  
  <p>my-element can be used without ng-model but the template of my-element contains input which always has ng-model. The my-attribute should be removed from my-element and added to input inside my-element. In my compile function in my-element directive I have:</p>
  
  <pre><code>var value = element.attr('my-attribute');
  element.remove('my-attribute'); 
  element.find('input').attr('my-attribute', value);
  </code></pre>
  
  <p>It works ok when attribute directive doesn't have require: 'ngModel'. But if I have ngModel required I get:</p>
  
  <blockquote>
    <p>Error: [$compile:ctreq] Controller 'ngModel', required by directive 'myAttribute', can't be found!</p>
  </blockquote>
  
  <p>Why? How can I fix this?</p>