I am building a site that illustrates common application vulnerabilities such as SQL Injection. I am using AngularJS and highlight.js to creat
A simpler way I just found is to use a filter:
app.filter('highlight', function($sce) {
return function(input, lang) {
if (lang && input) return hljs.highlight(lang, input).value;
return input;
}
}).filter('unsafe', function($sce) { return $sce.trustAsHtml; })
Then you can say:
The $sce needs to be injected into your app, and tells Angular to display the HTML raw - that you trust it.