Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Html tags not rendering inside div (ckeditor)

I'm using ckeditor to get what user has inputed in the textarea , but when I want to show/render that field in my page it just shows the html tags not the rendered one ! It's odd cause even tags aren't escaped and everything looks like a pure html syntax which is just not rendered ! what is stored in mongodb is this :

"longDesc" : "<p style=\"text-align: left;\">We need creation of <strong>7 animated banners</strong>.</p>\n\n<p style=\"text-align: left;\">We need to remake to dynamic form. We provide you open source data and technical specifications.</p>\n"

and am using angularjs double brace in view to show this expression .

{{job.longDesc}}

and the output exactly is :

<p style=\"text-align: left;\">We need creation of <strong>7 animated banners</strong>.</p>\n\n<p style=\"text-align: left;\">We need to remake to dynamic form. We provide you open source data and technical specifications.</p>\n
like image 845
user3078441 Avatar asked Feb 27 '26 02:02

user3078441


1 Answers

Take a look at ngBindHtml. You just need to:

$scope.myHTML = '<p>test</p>';

....

<div ng-controller="ExampleController">
 <p ng-bind-html="myHTML"></p>
</div>

You will need to include the ngSanitize in your app dependency to make the ng-bind-html work. Here is an Plunker example:

http://plnkr.co/edit/RRNyiwQAaHQfNqtHslCD?p=preview

like image 190
Renan Ferreira Avatar answered Feb 28 '26 15:02

Renan Ferreira



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!