Render HTML in Service Portal Comments widget

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2019 11:28 AM
I would like to modify the OOB comments widget on the ticket page to either:
- Display URLs in comments as links
or
- Render HTML in each comments box.
I see that the value of the comments is already bound to this element, so I'm stumped as to how to make it actually render HTML.
<p ng-if="::(e.element != 'attachment')" ng-bind-html="::e.value"></p>
If anyone has any experience with this, please let me know what I might be missing here.
Thanks,
Todd

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2019 11:38 AM
Hello Todd,
Put your html in an Anchor tag to make a link, or just put it in the p tag if you want show the URL
<p ng-if="::(e.element != 'attachment')">
<a ng-bind-html="::e.value"></a>
</p>
<p ng-if="::(e.element != 'attachment')" ng-bind-html="::e.value">{{::e.value}}</p>
To render a webpage from a URL, use an iframe.
<iframe src="Your link here height="500px" width="500px"></iframe>
Here is the W3C info about iframes.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2019 12:21 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-08-2019 09:02 AM
What I had to do was create a function which makes the value become true HTML.
I add this function to the Client Script:
$scope.toHtml = function(text) {
text = text.replace(/</g,"<");
text = text.replace(/>/g,">");
return $sce.trustAsHtml(text);
}
And updated the HTML template line to:
<p ng-if="::(e.element != 'attachment')" ng-bind-html="toHtml(e.value.toString())"></p>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-20-2019 11:48 AM
This worked for me as well!! -thx