The CreatorCon Call for Content is officially open! Get started here.

ng-bind-html is not working with style

Sneha39
Mega Guru

 

I have created a widget which is population html field on the portal but style is getting messed, its not showing color. ( u_class_name is html type field)

HTML :

<div id="modalTemplate" >
<div class="panel panel-default">
<div class="panel-heading">
</div>
<div class="panel-body wrapper-xl">
<div ng-bind-html="::data.name"></div> 
</div>
</div>

 

Server Script :

(function() {

var gr = new GlideRecord('u_class');
gr.query();
if (gr.next()) {
var obj = {};
data.name = gr.getValue('u_class_name');

}
})();

 

Client Controller :

function($scope,spUtil, $uibModal) {
var c = this;

c.openModal = function() {
c.modalInstance = $uibModal.open({
templateUrl: 'modalTemplate',
scope: $scope
});

}

c.closeModal = function() {
c.modalInstance.close();
}

}

1 ACCEPTED SOLUTION

Filipe Cruz
Kilo Sage

Hello Sneha,

Please check this community thread:

Displaying html fields in widget - Service Portal

From what I can see, you need to do some changes to your client controller:

Client Controller :

function($scope,spUtil, $uibModal, $sce) {
var c = this;

// Display HTML field
$scope.data.name = $sce.trustAsHtml($scope.data.name);

c.openModal = function() {
c.modalInstance = $uibModal.open({
templateUrl: 'modalTemplate',
scope: $scope
});

}

c.closeModal = function() {
c.modalInstance.close();
}

}

 

Check if this works!

Please, don't forget to mark my answer as correct if it solves your issue or mark it as helpful if it is relevant for you!

Best Regards,

Filipe Cruz

View solution in original post

7 REPLIES 7

Hello Sneha,

try to replace <div ng-bind-html="::data.name"></div> by
<div ng-bind-html="data.name"></div> 

Check if this helps!

Please, don't forget to mark my answer as correct if it solves your issue or mark it as helpful if it is relevant for you!

Best Regards,

Filipe Cruz

@Filipe Cruz  removing :: is not working. I guess i am writing wrong server script. ideally it should pick class name of current class id

Hello Sneha,

Yep, I think you are right.
Try to rewrite the server script and let me know your findings.

Best Regards,

Filipe Cruz