Is it possible to use the built in HTML escaping from angular outside of a binding?
The functionality (that angular uses that i wish to use elsewhere) is illustrated below
//in controller
$scope.blah = '<script>alert(1)</script>';
<!-- template -->
<p>{{blah}}</p>
This will render the text with HTML escaped. I want to use the same functionality to escape html, is there a way this can be exposed?
EDIT
I think my question might have been particularly unclear. I want to replicate the built-in functionality that escapes HTML automatically when binding to a scope variable in a template, but I am not using an angular template. The code runs in a controller, but I am injecting mixed content.
The following is a better example of what I'm trying to do. This is in a controller:
$http.get('/endpoint.json').success(function(data) {
someLib.setHTML('<a href="foo">' + data.name + '</a>');
});
I need to use HTML but I want to escape data.name, can I access the same functionality that angular itself uses?
<script>tags within scope variables, and what is the functionality you think you want to achieve from this