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:
File Upload Using Angular Js and Node Js28-05-2018 AngularJs Node js file upload multer module |
Example for Conditional Operator in php16-04-2017 php Conditional Operator example |
How to get id by using name attribute in javascript20-03-2017 html id name javascript |
How to redirect one page to another page in php20-03-2017 redirect php |
Change datepicker display format06-03-2017 datepicker angular js |