ngsanitize - HTML encoded String not translating correctly in AngularJS -


i have html encoded string this:

sign , <span class="strong">something     free!</span> 

when use ngsanitize , ng-bind-html in template this:

<p ng-bind-html="sometext"></p> 

i html decoded string:

sign , <span class="strong">something free!</span> 

but literally shows html decoded string in browser, instead of rendering html correctly.

how can have render correct html in dom?

you can decode html string first. here's working plunker example.

angular.module('app', ['ngsanitize'])   .controller('ctrl', ['$scope', '$sanitize', function($scope, $sanitize){     $scope.sometext = htmldecode("sign , &lt;span class=&quot;strong&quot;&gt;something     free!&lt;/span&gt;");      function htmldecode(input){        var e = document.createelement('div');       e.innerhtml = input;       return e.childnodes.length === 0 ? "" : e.childnodes[0].nodevalue;     } }]); 

** decode function taken this answer.


Comments

Popular posts from this blog

Android : Making Listview full screen -

javascript - Parse JSON from the body of the POST -

javascript - Chrome Extension: Interacting with iframe embedded within popup -