If you need to display raw HTML content to the page view with AngularJS, you can use the $sce service that comes with AngularJS. $sce stands for Strict Contextual Escaping. The service has trustAsHTML method with take some arbitrary text or HTML.
Example HTML content is
$scope.html = '<b>render me please</b>';
The html code is
<p class="text">{{html}}</p>
from the user side the html will display as
<b>render me please</b>
By using the below filter, the text will displayed as
render me please
The filter is
angular.module('test').filter('RenderHtmlText', function($sce) { return function(val) { return $sce.trustAsHtml(val); }; });
$sce is a service that provides Strict Contextual Escaping services to AngularJS.
You might also like:
Compare the Triplets | Javascript | hackerrank.com07-05-2020 hackerrank.com |
Check null values in JavaScript?04-02-2019 JavaScript null check null value |
Convert Time 24 hrs to 12 hrs format In javascript12-03-2017 date javascript 12hrs convert |
Filter for change Date format (MM-dd-yyyy) in Angular Js05-03-2017 mm-dd-yyyy date formats angular js |
Call a function every second or 5 seconds in javascript22-02-2017 setinterval function calling |