How to Unescaping HTML in Lightning Component

by Rijwan Mohmmed
2 comments
How-to-Unescaping-HTML-in-Lightning-Component

We can unescap the html by using this aura:unescapedHtml . This component is used to write the html content as it is without performing recalculation. Like we show our code in Blog without compile. Lets get more with a simple example.

Lightning Component :

<aura:component>
    <!--Handler-->
    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
     
    <!--Attributes-->
    <aura:attribute name="htmlstring" type="String" default=""/>
    
    <div class="slds-m-around--xx-large">
        With Render <aura:unescapedHtml value="{!v.htmlstring}"/>.
    </div>
	
	<div class="slds-m-around--xx-large">
        Without Render <span>{!v.htmlstring}</span>.
    </div>
   
</aura:component>

Lightning Controller :

({
	doInit : function(component, event, helper) {
		component.set("v.htmlstring", "<h1>Hello World!!</h1>");
	}
})
What’s your Reaction?
+1
0
+1
0
+1
0
+1
0
+1
0
+1
0

You may also like

2 comments

Jennie November 10, 2021 - 3:56 am

I am sure this paragraph has touched all
the internet viewers, its really really pleasant article on building up
new web site.

Reply
Ronda November 11, 2021 - 5:24 pm

That is really fascinating, You’re an overly skilled blogger.I have joined your rss feed and sit up for searchingfor extra of your great
post. Additionally, I have shared your site in my social networks

Reply

Leave a Comment

* By using this form you agree with the storage and handling of your data by this website.