title: Angularjs on Gmail : directive no executed
body: <p>I'm trying to manipulate GMail DOM with angularjs into a chrome extension.</p>
  
  <p>For the moment I have a basic app :</p>
  
  <pre><code>(function() { "use strict";
  
    var html = document.querySelector('html');
  
    html.classList.add('gmail-detect-response');
    angular.bootstrap(html, ['myGmailApp']);
    html.classList.add('ng-app');
    html.classList.add('ng-csp');
  
  }());
  </code></pre>
  
  <p>And a directive :</p>
  
  <pre><code>(function(){ 'use strict';
    angular.module('myGmailApp').directive('gmailDetectResponse', detectResponse);
  
    function detectResponse(){
      return {
        restrict: 'A',
        link: function(scope, element, attrs){
          var target = document.body;
          var config = {
            attributes: true,
            childList: true,
            subtree: true
          };
  
          var observer = new MutationObserver(function(mutations){
            mutations.forEach(function(mutation){
              if(mutation.addedNodes.length &gt; 0){
                console.log('mutmut');
                var responseDivs = document.getElementsByClassName("gH acX");
                for(var i = 0; i &lt; responseDivs.length; i++){
                  if(responseDivs[i].getAttribute('gTrelloSend') == null){
                    responseDivs[i].setAttribute('gTrelloSend', '');
                    var para = document.createElement('p');
                    var textNode = document.createTextNode('TEST');
                    para.appendChild(textNode);
                    responseDivs[i].insertBefore(para, responseDivs[i].firstElementChild);
                  }
                }
              }
            });
          });
  
          observer.observe(target, config);
        }
      }
    };
  })();
  </code></pre>
  
  <p>My mutation observer works fine if I put it in a basic js file.
  Why my directive isn't executed ?</p>
  
  <p>My goal is to detect all "response divs" into Gmail in order to create a button who can call an angularjs controller.</p>
  
  <p>Thanks a lot !</p>