Reputation: 768
JS:
$scope.test = 'Amidación';
HTML:
<span ng-bind-html="test"></span>
OUTPUT:
Amidaci�n
Issue: I am getting the latin character ó in output as � junk character, i tried ngsanitize also but it didn't resolved. Any idea how it can render correctly ?
Note: Can't convert the latin character into ascii or hexadecimal because it is a Json data.
Upvotes: 1
Views: 1106
Reputation: 136144
Basically you need to sanitize your text using $sce
, for that you needto make that html as trusted using $sce.trustAsHtml
method.
Code
angular.module('app', [])
.controller('MainController', ["$scope", "$http", '$sce',
function($scope, $http, $sce) {
$scope.test = $sce.trustAsHtml('Amidación');
}
]);
Update
More better way would be you could create your own filter that can be act as reusable component
Markup
<span ng-bind-html="test | unsafe"></span>
Filter
app.filter('unsafe', function($sce) {
return $sce.trustAsHtml;
});
Upvotes: 1