- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-06-2022 10:19 AM
I have a requirement that generates html elements from the server script (specifically from within a script include).
Specifically the html elements are formatted table row cells that are meant to be passed to the html body template after some information is selected within the widget. All of that seems to work fine but my problem is that when it gets added to the html it's being translated to show the actual tags instead of an actual html element. I'm wondering if there is something i need to do before i try and pass it back to the html body for reference i made a simplified example of what i see in my PDI:
HTML Body Template
<div>
<!-- your widget template -->
<span id="test-span">
{{c.data.something.test_data}}
</span>
</div>
Client Script:
api.controller=function() {
/* widget controller */
var c = this;
alert(c.data.something.test_data);
c.updateItem = function (){
console.log("updateItem");
alert("triggered by button");
}
};
Server Script:
(function() {
/* populate the 'data' object */
/* e.g., data.table = $sp.getValue('table'); */
data.something = {};
data.something.test_data = "<h1>test something</h1>" +
"<h1>test something</h1>" +
"\<h1\>test something\<\/h1\>";
})();
Result:
Solved! Go to Solution.
- Labels:
-
Service Portal Development
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-06-2022 10:34 AM
You can use ng-bind-html:
Replace "{{c.data.something.test_data}}" with:
<p ng-bind-html="data.something.test_data"></p>
Please mark helpful or mark as correct answer if applicable, thanks! 🙂
Best regards,
Sebastian Laursen
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-06-2022 11:32 AM
Agree . Did not notice completely he has written HTML Tags in Server script of his widget.
Need to use ng-bind-html here.
Thanks for pointing out.
Regadrs,
Shloke
Regards,
Shloke