I'm trying to render html which is saved in json.
It's looks like this html in json is escaped:
{"desc": [{
"label": "Long Label",
"label-short": "short Label",
"text": "Text.<br \/> text <strong class=\"class\"> text <\/strong> foo."
}]}
I have factory service to get json file.
getFile : function() {
return $http({
url: 'data/foo.json',
method: 'GET'
})
}
Controller:
$scope.decodeJson = function(data){
return Data.decode(data);
}
var handleSuccessGetFile = function(data, status) {
$scope.Desc = data;
};
Data.getFile().success(handleSuccessGetFile).error(handleErrorGetFile);
Now i want to render $scope.Desc
<accordion>
<accordion-group ng-repeat="desc in Desc.desc" heading="{{desc.label}}">
<p>
{{decodeJson(desc.text)}}
</p>
</accordion-group>
</accordion>
But rendered desc.text is rendered as string not as html, how can i transform it to html?
Based on https://code.google.com/p/jsool/source/browse/jsool-site/js/util/Encoder.js?r=176
I create service decode
decode: function(string){
return string.replace(/&#[0-9]+;/g,function(text,index){
return String.fromCharCode(text.match(/[0-9]+/)[0]);
});
}
but it's still rendered as string.