0

I render a button saved from SQL Server database. View source for the button looks like the following -

<button id="btn" class="mainBtn" ng-click="OpenBtn('btn')" >Do something</button>

This button is part of a MainDiv which looks like following -

<div id="MainDIV"  ng-bind-html="MainDIVHTML">

I assign MainDIVHTML value as follows -

 $scope.MainDIVHTML= $sce.trustAsHtml(entity.MainDIVHTML);

Where entity.MainDIVHTML is the saved HTML from database.

mainBtn is inside the entity.MainDIVHTML

The saved HTML and the page where I am using saved HTML share the Angular.js controller.

I am not able to execute - ng-click="OpenBtn('btn')" event.

The markup (HTML) is shown correctly though.

James
  • 20,957
  • 5
  • 26
  • 41
  • Does this answer your question? [Accessing ng-click when rendered via $sce.trustAsHtml](https://stackoverflow.com/questions/41787478/accessing-ng-click-when-rendered-via-sce-trustashtml) – James Oct 01 '21 at 17:43
  • Yes. That worked good for me. Thanks for the suggestion. –  Oct 01 '21 at 21:02

0 Answers0