0

I am using TinyMCE to style content that the user then saves to the database, an example of what the user could be saving is as below:

<ol><li><em>This</em> is a <span style="text-decoration: underline;" data-mce-style="text-decoration: underline;">HTML</span> email that <strong><span style="font-family: 'times new roman', times;">should</span></strong> <span style="font-family: tahoma, arial, helvetica, sans-serif;">contain</span> different <span style="font-family: arial, helvetica, sans-serif;">fonts</span> in weights with lists and links...</li></ol>

I am currently using ng-bind-html to display this HTML content in my view, however, it appears to be stripping the inline styles. Here is my source from the browser:

<ol><li><em>This</em> is a <span>HTML</span> email that <strong><span>should</span></strong> <span>contain</span> different <span>fonts</span> in weights with lists and links...</li></ol>

Is there a way in which I can keep these inline styles in the view?

ChrisBratherton
  • 1,540
  • 6
  • 26
  • 63

2 Answers2

1

you could try marking your HTML as trusted, passing in $sce, as:

yourApp.controller('someCtrl', ['$scope', '$sce', function($scope, $sce) {      
  $scope.some_html = $sce.trustAsHtml(some_html_content);
}]);
Sudhir Bastakoti
  • 99,167
  • 15
  • 158
  • 162
0

If you are using Angular 1.2+ you have do this:

$scope.htmlToBind = $sce.trustAsHtml(yourHtml);

See documentation for more details.

alisabzevari
  • 8,008
  • 6
  • 43
  • 67