Reputation: 21
I'm trying to call function with parameter that contains html tags and special characters:
$scope.translate is JSON like {"phrase": "phrase1"}
JS:
$scope.t = function(phrase) {
if ($scope.translate[phrase]) {
return $scope.translate[phrase];
} else {
return phrase;
}
}
HTML:
<label class="sub-label" for="" >{{t("Fields required are marked with <span> * </ span>")}}</label>
When there are special characters - the function is not processed, but instead shows the code. I guess that this is the result of processing variables in angularJS. How do I properly solve this problem?
Upvotes: 0
Views: 1049
Reputation: 692
If you have this hardcoded in your HTML template, you will need to put entities for special characters. This means using
<label class="sub-label" for="" >{{t("Fields required are marked with <span> * </ span>")}}</label>
instead.
Upvotes: 1
Reputation: 1304
Might have to include ngSanitize package in your app, and then use ngBindHtml directive.
Upvotes: 0