title: ng-click doesn't work on dynamic DOM AngularJS?
body: <p>I have a controller like this:</p>
  
  <pre><code>@VariantModalCtrl = ($scope) -&gt;
    $scope.upload_variant_image = -&gt;
      alert("test")
  </code></pre>
  
  <p>When I try to call upload_variant_image function using ng-click, it only works when binding to a static DOM (when the DOM loads), I have a link like this:</p>
  
  <pre><code>&lt;%= link_to "test", "" , "ng-click" =&gt; "upload_variant_image()" %&gt;
  </code></pre>
  
  <p>but this element is dynamically added after the DOM is loaded, so ng-click doesn't work. </p>
  
  <p><strong>Update</strong>
  Just found part of my answer using $compile function:
  <a href="https://stackoverflow.com/questions/11771513/angularjs-jquery-how-to-get-dynamic-content-working-in-angularjs">AngularJS + JQuery : How to get dynamic content working in angularjs</a></p>
  
  <p>BUT it doesn’t work when I update the DOM like this in Rails:</p>
  
  <pre><code>$(".modal-body").html($compile("&lt;%= j render("/variants/form", :variant =&gt; @variant) %&gt;")(scope));
  </code></pre>