Skip to content

Instantly share code, notes, and snippets.

@abhilash0001
Last active August 29, 2015 14:03
Show Gist options
  • Save abhilash0001/fff8b577125e05a21983 to your computer and use it in GitHub Desktop.
Save abhilash0001/fff8b577125e05a21983 to your computer and use it in GitHub Desktop.
AngularJS | Inject HTML
/*
How do I inject HTML?
The simplest and the most flexible way is to create a filter.
*/
angular.module('mfgapp')
.filter('to_trusted', ['$sce', function($sce){
return function(text) {
return $sce.trustAsHtml(text);
};
}]);
<aside id="sidebar" ng-bind-html="sidebar.content | to_trusted"></aside>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment