Getting data with format preserving from HTML field in serivce portal?

dvp
Mega Sage
Mega Sage

Hello all,

I was wondering if there is way to preserve the format in HTML field and display it in service portal page

Thanks for your help!!!

1 ACCEPTED SOLUTION

I figured it. We just need to use ng-html angular directory.


View solution in original post

8 REPLIES 8

nasrin786
Kilo Expert

Hi Dvp



Please go through these links: (It will helpful to you)



https://docs.servicenow.com/bundle/istanbul-servicenow-platform/page/build/service-portal/concept/c_...



https://community.servicenow.com/community/develop/blog/2016/10/04/service-portal-getting-familiar-w...




Thanks&Regards,


Nasrin Syed


                                                                                                                                                              Hit Like/Helpful/Correct, if applicable.


Hi,


Yes try this once and let me know how it works,



HTML template


  1.   <div>  
  2.   Data from catalog variable:  
  3.   <h1>{{ c.data.message }}</h1>  
  4.   </div>  

Client Script Controller


  1. function($scope) {  
  2.         var c = this;  
  3.  
  4.         //Watch for changes in the name variable  
  5.         $scope.$watch(function () {  
  6.                   return $scope.page.g_form.getValue('name');  
  7.         }, function (value) {  
  8.         //Update local data object with data from variable  
  9.         c.data.message = value ? 'Content of name variable: ' + value : '';  
  10. });  
  11. }

Thanks and Regards,


Sarika V



Please mark Correct or Helpful or Hit Like


dvp
Mega Sage
Mega Sage

Let me give you more details about what I'm trying to achieve.



Here is the field on the knowledge form with type as HTML



Capture.JPG



When i tried to pass on the data from server to View using data object I'm getting this



Capture2.JPG


The HTML view is not at all in a readable format because of all the tags



So i was wondering if there is a way to preserve format that is on the kb form.



Thanks