Displaying html fields in widget - Service Portal

jimnicholson
Giga Guru

Hey All,

I have a task with an HTML field, and I want to display the HTML as it shows on the screen, but when I return it to the widget, I just get the tags and no formatting.

Is there any way to transform this to show html?   Is this where I would use something like "ng-bind-html"?

Still fairly green when it comes to angular and widget development but learning on the fly.

Any help is greatly appreciated.

Thank you very much in advance,

Jim

1 ACCEPTED SOLUTION

Anais Geisen
Tera Expert

Hi,



Yes there is the bind html.


Here is an example of HTML code:


<div ng-bind-html="::data.desc" "></div> (where data.desc is your HTML field that you get in the server part)



and the client side:


function($scope, $sce) {


  /* widget controller */


  var c = this;



// Display HTML field


$scope.data.desc = $sce.trustAsHtml($scope.data.desc);



}



Please mark it helpful



Regards


View solution in original post

7 REPLIES 7

You're welcome



Anaí¯s


I am trying to do something similar but it just keeps showing up as [object Object] on my widget in the portal. 

 

My HTML field is u_approval_instructions

 

Added the HTML:

<div ng-bind-html="::data.u_approval_instructions"></div>

Client Script:

function ($scope, $animate, $rootScope, $sce) {
  $scope.$watch("data.task", function() {
    $scope.task = $scope.data.task; // copy for shortcuts above
  })
  
}
function($scope, $sce) {
   /* widget controller */
   var c = this;
// Display HTML field
$scope.data.u_approval_instruction = $sce.trustAsHtml($scope.data.u_approval_instruction);
}

Server Script:

data.u_approval_instructions = task.u_approval_instructions;

This is the result I am getting:

find_real_file.png

 

Am I missing something?

YASSS Thank you!!