Filter for insert HTML in Angular Js

filter
show html
angular js
html

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:

Use java script file client side and server side at a time in node js

30-07-2017 node js include call javascript

How To Get Your Blogs Posts Using Blogger API

30-07-2017 blogger api json php

How to insert bulk information into database in single query execution

18-03-2017 insert sql bulk database

Sanitization in java sript

14-03-2017 sanitization java script

How to convert html to pdf in Node js

12-03-2017 pdf convert html node js