2

i use the markdown module in node.js , when i get some text from mongodb , i turn it to markdown :

newsList.forEach(function (news) {
    news.publishContent = markdown.toHTML(news.publishContent);
})

and send the data to the html via angular :

<p ng-bind="nl.publishContent" ng-show="!isEdit"></p>

but the result in the html page is

enter image description here

the html elements doesn't resolve into html elements , they are toString into the html , how to make it resolve into html ?

1 Answer 1

1

Use ng-bind-html instead of ng-bind.

Sign up to request clarification or add additional context in comments.

2 Comments

thank your for helping , when i change to ng-bind-html , the angular tell me "Error: [$sce:unsafe] Attempting to use an unsafe value in a safe context." , how should i fix this problem?
I belive you have to sanitise your HTML before binding it to the paragraph using $sce.HTML(delegate) or $sce.getTrustedHtml(value) - more details here: docs.angularjs.org/api/ng/service/$sce

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.