Salesforce tutorials in Apex, Lightning Web Components, and Flow — plus honest career guidance for admins, developers, and job seekers trying to break into the ecosystem.
Hello Friends as we know aura: if on lightning component for rendering section/div. lets check in details
we can not use [&& ,AND ,||, OR] operator for use multiple conditions in isTrue attribute with In aura:if tag. we can use logical Functions in aura:if tag like or(), and() .
Sample code for how to use multiple Boolean conditions in aura:if tag.
<aura:component > <aura:attribute name="FlagOneisTrue" type="boolean" default="true"/> <aura:attribute name="FlagTwoisFalse" type="boolean" default="false"/> <aura:attribute name="FlagthreeisTrue" type="boolean" default="true"/> <aura:attribute name="FlagFourisFalse" type="boolean" default="false"/> <!--aura:if sample code with and --> <aura:if isTrue="{!and(v.FlagOneisTrue, v.FlagthreeisTrue)}" > <div style="padding:15px; background-color:LightBlue"> Out Come ==> this div show because both attribute is true beacse we use and </div> </aura:if> <!--aura:if with aura:set sample with or--> <aura:if isTrue="{!or(v.FlagFourisFalse, v.FlagTwoisFalse)}" > <div style="padding:15px; background-color:GreenYellow"> Out Come ==> this div show because one attribute is true,beacse we use or </div> <aura:set attribute="else"> <div style="padding:15px; background-color:GreenYellow"> Out Come ==> this aura:set div show because both attribute is false </div> </aura:set> </aura:if> <!--aura:if with nested and condition with and along with or--> <aura:if isTrue="{!or(and(v.FlagOneisTrue, v.FlagthreeisTrue) , v.FlagTwoisFalse ) }" > <div style="padding:15px; background-color:LightGreen "> Out Come ===> nested condition div show because in statment 1 of or()condition returns true. </div> </aura:if> </aura:component>
Here, we fire the event from Lightning Web Component to Aura Component. Instead of event.fire in an Aura Component, use the standard DOM Method, this.dispatchEvent(myEvent), in Lightning Web Component.
The first argument in the CustomEvent constructor set the name to be ‘txtChange’.
The second argument is an object that configures the object behaviour. In this object, we set the “detail” which is payload event. A handling component can read for data. In this case, we’re passing the “v”.And In variable(v), we set the “txtInput.value”.
Step 2) Create Lightning Aura Component with name “EventDemo”
Here, we link the Lightning Web Component and handle the event fired by LWC using “ontxtChange”.In LWC, we use “txtChange” name in CustomEvent constructor and when we handle the event we add the “on”.