1

I have text $scope.post.details = <b>hello</b>

I have this directive:

var app = angular.module('mobApp.services');
app.directive('compile', ['$compile', function ($compile) {
    return function(scope, element, attrs) {
        scope.$watch(attrs.compile, function(html) {
            element.html(html);
            $compile(element.contents())(scope);
        });
    };
}]);

I am using like

problem is &lt;b&gt; is not getting render as <b>

Manish Kumar
  • 10,214
  • 25
  • 77
  • 147

1 Answers1

1

Well I have a JavaScript function that converts string to HTML. You could use this function to convert it into HTML

function htmlDecode(input){
  var e = document.createElement('div');
  e.innerHTML = input;
  return e.childNodes[0].nodeValue;
}
Muhammed Neswine
  • 2,028
  • 1
  • 20
  • 20