Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

angularjs - Accessing ng-click when rendered via $sce.trustAsHtml

How do i get access to the ng-click function (updateRating) in the below?

https://jsfiddle.net/by2jax5v/171/

I'm using $sce.trustAsHtml to render $scope.content

$scope.bindHTML = $sce.trustAsHtml($scope.content);
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Your above code does get compiled but it is sanitized by angular js considering an anchor tag as insecure, therefore ng-click does not work.

what you want to achieve can be achieved by using ng-html-compile by francis bouvier instead of ng-bind-html. It the thinnest library i have seen just 1kb. https://github.com/francisbouvier/ng_html_compile

also refer to https://stackoverflow.com/a/41790235


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...