1

I am using jQuery datatable and wanted to attach an ng-click on an <a> tag. The datatable code which does the same is below:

columns : [{
                type : "html",
                data : 'abcd',
                sTitle : 'xyz',
                render : function(data) {
                    return "<a href='javascript:void(0)' ng-click='hello()'>Hi</a>";
                }
         }]

ng-click is not getting called, so I tried:

return $compile("<a href='javascript:void(0)' ng-click='hello()'>Hi</a>")($scope);

which is returning a jQuery object and not the string.

Also, what is the correct way for attaching directives for dynamically created HTML elements?

alex
  • 6,818
  • 9
  • 52
  • 103
lintu
  • 1,092
  • 11
  • 24

0 Answers0