I have a problem with ng-bind-html directive.
I get the email HTML data from external services (not trusted), so it may happen that I receive <script> tag inside message body. However I don't want to execute this JS code on my page. I am using ng-bind-html directive for this.
I created an example for this and my problem is that alert() function is executed. How to deny to do this?
var app = angular.module('myApp', ['ngSanitize']);
app.controller('MainCtrl', function ($sce, $scope) {
$scope.text = " <script>alert(222)</script> <script>alert(222)</script>";
});
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app="myApp" ng-controller="MainCtrl">
<div ng-bind-html="text"></div>
</div>
alertfunction. The source of html is not trusted so it might be anything in the script tags. My intention is to not execute this kind of code at all. I usealertonly as an example