0

Approval_notes__c is a formula field that contains html tags.

I display it in a Lightning web component, the lightning-formatted-rich-text component work perfectly and display the text correctly. I want to display the text also as help note in the title attribute. Is there a way to remove html tags from it without using JavaScript?

<lightning-formatted-rich-text title={Approval_notes__c} class="slds-truncate" value={Approval_notes__c}></lightning-formatted-rich-text>

enter image description here

1 Answer 1

3

you can set title attribute separetely for lightning-formatted-rich-text tag

html

<lightning-formatted-rich-text
    title={preparedTitle}
    value={Approval_notes__c}>
</lightning-formatted-rich-text>

js

...
get preparedTitle(){
    //prepare desired title without special symbols
    return this.Approval_notes__c.replace(.....//correct regex goes here)
}
...
2
  • Thanks for you answer, I am trying to do that without Js
    – Raphael D
    May 12, 2021 at 11:03
  • 1
    unfortunately, it is not possible for now to do just by means of markup, as lwc markup do not have any markup expressions (but aura has) It will require an additional step to prepare the sanitized string for the title (in apex, or in js) May 12, 2021 at 11:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .