how to parse custom html element using ng-bind-html in angularjs -



how to parse custom html element using ng-bind-html in angularjs -

i need parse string using ng-bind-html. string contains custom html tags in it. while parsing using ng-bind-html gives me error $sanitize:badparse.

please see fiddle error: http://jsfiddle.net/8zs4h/2/

while reading questions in stackoverflow , in google found there solution if utilize $sce.trustashtml().

this solves error issue couldn't parse custom html element. can see updated fiddle here: http://jsfiddle.net/8zs4h/3/

i scratching hard head find solution.

edit : add together more info, getting string rss feed, can have "<http>" or "<http" tags also. failing. if string <http://www.<em>whitehouse</em>.gov/omb/circulars/a076/ should gives output http://www.<em>whitehouse</em>.gov/omb/circulars/a076/

well, managed working tags anchor, underline , bold without problem, look:

fiddle

angular.module('ngbindhtmlexample', ['ngsanitize']) .controller('ngbindhtmlctrl', ['$scope', function ngbindhtmlctrl($scope) { $scope.myhtml = '<a href=\"http://google.com\">link</a> contests <u>of omb</u> <b>circular</b> a-76'; }]) .filter('to_trusted', ['$sce', function($sce){ homecoming function(text) { homecoming $sce.trustashtml(text); }; }]);

seems it's parsed correctly

angularjs ng-bind-html

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -