You need to sign in to do that
Don't have an account?
Luciano Roberto
Controller.js
How pass value from controller to view in tag <h2>
Folks,
I'm configuring a toast and I need to pass the controller's text to the <h2> tag of the view of the lightning component
TestAlert.cmp
<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId,lightning:actionOverride,lightning:backgroundUtilityItem" access="GLOBAL" controller="AlertController"> <aura:attribute name="Alert" type="Alert__c" default="{'sobjectType': 'Alert__c', 'Tipo_de_Alerta__c': '', 'Name': '', 'Alerta1__c': '' }"/> <aura:handler name="init" value="{!this}" action="{!c.doInit}"/> <div class="demo-only" style="height: 4rem;"> <div class="slds-notify_container slds-is-relative"> <div aura:id="alerta" role="status"> <div class="slds-notify__content"> <h2 class="slds-text-heading_small "> Alert message here </h2> <lightning:buttonIcon iconName="utility:close" variant="bare" alternativeText="Close" iconClass="{!v.type == 'warning' ? 'light' : 'dark'}" size="small" class="slds-button slds-button_icon slds-notify__close slds-button_icon-inverse" onclick="{!c.close}"/> </div> </div> </div> </div> </aura:component>
Controller.js
doInit : function(component, event, helper) { var tipoAlerta = component.find( "alerta" ); $A.util.addClass( tipoAlerta, "slds-notify" ); $A.util.addClass( tipoAlerta, "slds-notify_toast" ); $A.util.addClass( tipoAlerta, "slds-theme_success" ); //Code to pass text to view in tag <h2> </h2> }
All Answers
1. Set the Controller HTML code into one of the attributes
2. Render the value in UI using the aura:unesapeHTML code
Thanks Raj, but you are experiencing an error
Tanks so mutch