Follow by Email

AngularJS Filter for HTML parsing

AngularJS - Filter for HTML parsing   
                                                               
1) Include sanitize library :
 Url : https://ajax.googleapis.com/ajax/libs/angularjs/1.4.1/angular-sanitize.js

2) Add below code in the app.js file so that filter is avialable across the whole application :
app.filter('parseHTML', function($sce) {
    return function(val) {
        return $sce.trustAsHtml(val);
    };
});

3) Using filter in the views :
<span ng-bind-html="feed.long_desc | parseHTML">{{feed.long_desc}}</span>