spModal.open({message: doesn't accept HTML tags?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-31-2020 05:39 AM
Hi everyone,
I'm trying to make a simple widget that would display a modal window, with contents taken from a dot walked HTML type field.
But it seems that the HTML tags get stripped away when it gets passed to the message key in spModal.open()'s first parameter Object.
Logging $scope.data shows that the HTML tags get captured properly by the Server Script in the Widget below...
HTML:
<div>
<button type="button" class="btn btn-primary btn-block"
ng-click="c.htmlModal()"> HTML box </button>
</div>
Client Script:
function(spModal) {
var c = this; c.htmlModal = function() {
spModal.open({
message: c.data.got,
buttons: []
})
}
}
Server Script:
(function() {
data.record = $sp.getRecord();
var lookup = new GlideRecord(data.record.sys_class_name);
lookup.get(data.record.getUniqueValue());
data.got = lookup.html_field.toString();
})();
...
But the modal window displays the text without the formatting applied:
and Inspecting the element shows that the HTML tags are now stripped:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-31-2020 06:10 AM
It is inserted using "ng-bind-html" by default that will sanitize the HTML:
Evaluates the expression and inserts the resulting HTML into the element in a secure way. By default, the resulting HTML content will be sanitized using the $sanitize service.
https://docs.angularjs.org/api/ng/directive/ngBindHtml
What that means is it will remove a lot, but leaves the tags in place as you see in your screenshots as well.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-26-2020 12:10 AM