Angularjs: Latin / Spanish character showing as junk character -
js:
$scope.test = 'amidación';
html:
<span ng-bind-html="test"></span>
output:
amidaci�n
issue: getting latin character ó in output � junk character, tried ngsanitize didn't resolved. idea how can render correctly ?
note: can't convert latin character ascii or hexadecimal because json data.
basically need sanitize text using $sce
, needto make html 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 create own filter can act reusable component
markup
<span ng-bind-html="test | unsafe"></span>
filter
app.filter('unsafe', function($sce) { return $sce.trustashtml; });
Comments
Post a Comment