markdown - in angularJS, how to render model containing markup as markup (unescaped) -
im trying make markdown editor preview via angular filter calling showdown
<textarea ng-model="data.text"></textarea> <div class="preview">{{data.text|markdown}}</div> i managed convert markdown markup on fly html when rendered actual output on screen :
<h1 id="thisisaheader">this header</h1>
it looks resulting markup escaped. how render unescaped?
you need use ng-bind-html-unsafe:
<div class="preview" ng-bind-html-unsafe="data.text|markdown"></div> it's guarantee content trustful.
if happen using angular 1.2 rc1, should use ng-bind-html along new strict contextual escaping service ($sce short).
Comments
Post a Comment