I need to know how to properly decode HTML symbols in AngularJS for input type controls.
I am binding HTML input type='text' and textarea controls with AngularJS. The data I want to bind may contain symbols that have already been encoded and saved in database.
I know it is pretty straightforward to do this on a div or a p tags using $sce.trustAsHtml() and ng-bind-html (see below function) but I don't know how to do that for input type controls.
app.filter('trusted', ['$sce', function ($sce) {
var div = document.createElement('div');
return function (text) {
div.innerHTML = text;
return $sce.trustAsHtml(div.textContent);
};
}]);
Example text from database are:
's airports facing holiday disruption? new, and inflation has been much higher than it is now, so why do groceries suddenly seem more expensive than ever?I tried doing something similar (as above code), but this doesn't work.
$scope.ConvertToHtmlText = function (text) {
if(typeof text != typeof undefined)
return $sce.trustAsHtml(text);
};
<input type="text" class="form-control xts" id="title" name="title" value="{{ConvertToHtmlText(Post.Title)}}">