I am getting data from a custom field(Article__c) on a Knowledge Article which contains HTML data. When I serialize this data and return it to a VF page I am getting HTML characters that should be encoded as › or — that are simply outputting the characters - I need these to be encoded.
Sample Output
<strong>Settings</strong> › <strong>Account Settings</strong> › <strong>Users</strong>
Expected Output
<strong>Settings</strong> › <strong>Account Settings</strong> › <strong>Users</strong>
Apex
public with sharing class angularArticle {
public String getArticleJSON() {
list<Public__kav> articles = [SELECT Article__c,Id,Summary,Title,UrlName FROM Public__kav];
String articleJSON = JSON.serialize(articles);
return articleJSON;
}
}
Visualforce
<apex:page controller="angularArticle" showheader="false" applyBodyTag="false" applyhtmlTag="false" standardStylesheets="false">
<html ng-app="app">
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular.min.js"></script>
</head>
<body>
{{ article }}
</body>
<script type="text/javascript">
var app = angular.module('app', []);
app.run(function($rootScope) {
$rootScope.article = {!articleJSON};
});
</script>
</html>
</apex:page>