Aniruddha Das Aniruddha Das - 1 month ago 19
AngularJS Question

ng-click is removed by ngsanitize

I am getting setting some html text in my

$scope
variable which also contains
ng-click
attribute so that it on click of a link it will call angular controller function.

$scope.message = "dum messge<a data-ng-click='loadCalenderData()'>retry</a>";

//view
<div ng-bind-html="message"></div>


I tried both
data-ng-click
and
ng-click
but no luck.

Answer

Because it's not $compiled. When you bind-html, that doesn't tell Angular to search through that HTML and compile directives within it. You'll need a custom directive for this.

Check this link https://www.reddit.com/r/angularjs/comments/312mbg/ngclick_on_element_inserted_using_ngbindhtml_not/