Skip to content

Instantly share code, notes, and snippets.

@sjarifHD
Last active December 23, 2015 05:44
Show Gist options
  • Select an option

  • Save sjarifHD/87bcaa8a321f6947292a to your computer and use it in GitHub Desktop.

Select an option

Save sjarifHD/87bcaa8a321f6947292a to your computer and use it in GitHub Desktop.
Render HTML object with Angular template
var app = angular.module('myApp', []);
// some code to retrieve data or route here
// use angular filter to render HTML object with angular template
app.filter('rawHtml', ['$sce', function ($sce) {
return function (val) {
return $sce.trustAsHtml(val);
};
}]);
<!-- Usage in html template , ng-bind-html -->
<div ng-repeat="data in datas">
<h4>{{ data.title }}</h4>
<div ng-bind-html="data.content | rawHtml"></div>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment