title: Angular modal instance can't read DOM elements
body: <p>Hi im playing with angular modal instance..</p>
  
  <p>But when i declare a querySelector in the modal controler it gives console error of Cannot read property 'querySelector' of null</p>
  
  <p>HTML</p>
  
  <pre><code>      &lt;body&gt;
  
              &lt;div id="signature-pad"&gt;
  
                      &lt;canvas width="300" height="300"&gt;&lt;/canvas&gt;
  
                      &lt;div class="description"&gt;Sign above&lt;/div&gt;
                      &lt;button class="button clear" data-action="clear"&gt;Clear&lt;/button&gt;
  
              &lt;/div&gt;
  
  
  
  &lt;/body&gt;
  
      &lt;div class="modal-footer"&gt;
          &lt;button class="btn btn-success btn-lg" ng-click="ok();"&gt;Gem &amp; Godkend&lt;/button&gt;
          &lt;button class="btn btn-warning btn-lg" ng-click="cancel()"&gt;Annuler&lt;/button&gt;
     &lt;/div&gt;
  </code></pre>
  
  <p>JS - ModalInstanceController</p>
  
  <pre><code>var ModalInstanceCtrl = function ($scope, $modalInstance) {
  
  
              $scope.init = function() {
                  var wrapper = document.getElementById("signature-pad"),
                      clearButton = wrapper.querySelector("[data-action=clear]"),
                      canvas = wrapper.querySelector("canvas"),
                      signaturePad;
  
                  signaturePad = new SignaturePad(canvas);
  
                  clearButton.addEventListener("click", function (event) {
                      signaturePad.clear();
                  });
                  $scope.ok = function () {
                      $modalInstance.close(signaturePad.toDataURL());
                  };
  
                  $scope.cancel = function () {
                      $modalInstance.dismiss('cancel');
                  };
  
  
              };
  
          $modalInstance.opened.then($scope.init);
  
          };
  </code></pre>
  
  <p>So it seams like it, can't find dom elements in model .. :s
  As you i can i tried to load, model into dom first with    <code>$modalInstance.opened.then($scope.init);</code>
  But this dosen't work either</p>