Last active
December 23, 2015 05:44
-
-
Save sjarifHD/87bcaa8a321f6947292a to your computer and use it in GitHub Desktop.
Render HTML object with Angular template
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); | |
| }; | |
| }]); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!-- 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