primeng icon indicating copy to clipboard operation
primeng copied to clipboard

p-Message do not show html content anymore

Open fxvits opened this issue 6 years ago • 2 comments

[X ] bug report => Search github for a similar issue or PR before submitting

  • Angular version: 9.X
  • PrimeNG version: 9.0.6

In our project, we are using MessageService to display alerts having html content. But p-messages do not render the hmtl content anymore. (We do not use any template in p-messages)

After checking the code I have successfully find a workaround by using the attribute [escape]='false' of the p-messages components. I seems the problem is related of the escape default value (true) and caused by the usage of interpolation to display the message in the template html code instead of the [innerHTML]. Here below the html code from messages.ts file.

<li *ngFor="let msg of value"> <div *ngIf="!escape; else escapeOut"> <span *ngIf="msg.summary" class="ui-messages-summary" [innerHTML]="msg.summary"></span> <span *ngIf="msg.detail" class="ui-messages-detail" [innerHTML]="msg.detail"></span> </div> <ng-template #escapeOut> <span *ngIf="msg.summary" class="ui-messages-summary">{{msg.summary}}</span> <span *ngIf="msg.detail" class="ui-messages-detail">{{msg.detail}}</span> </ng-template> </li>

fxvits avatar May 11 '20 13:05 fxvits

I confirm that we also have this problem. Thank you @fxvits for the workaround.

sombe avatar May 28 '20 08:05 sombe

You can use escape="false" in message. <p-message ... [escape]="false">

yigitfindikli avatar Nov 23 '20 13:11 yigitfindikli