@Steve TibbetYou can use an application event
The main component handles the app event in reception and changes he value of the <aura:if><!--c:appEvent-->
<aura:event type="APPLICATION">
<aura:attribute name="message" type="String"/>
</aura:event>
<aura:component access="global" implements="flexipage:availableForAllPageTypes" controller="MassEmailController">
<aura:handler event="c:appEvent" action="{!c.handleApplicationEvent}"/>
<aura:handler name="init" value="{! this }" action="{! c.initialize }"/>
<aura:if isTrue="{!v.showCmp}">
.....
</aura:if>
</aura:component>
handleApplicationEvent : function(cmp, event) {
var message = event.getParam("message");
if (message == 'French') {
cmp.set('v.showCmp',false);
} else {
cmp.set('v.showCmp',true);
}
},
The other component (anywhere on the page) fires the app event with the language in the message (parameter of the app event) when the value changes (here a radio group)
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,force:lightningQuickAction" access="global" >
<aura:registerEvent name="appEvent" type="c:appEvent"/>
<aura:attribute name="options" type="List" default="[
{'label': 'French', 'value': 'French'},
{'label': 'English', 'value': 'English'}
]"/>
<aura:attribute name="value" type="String" default="English"/>
<lightning:radioGroup name="radioGroup"
label="Radio Group"
options="{! v.options }"
value="{! v.value }"
onchange="{! c.handleChange }"
type="radio"/>
</aura:component>
({
handleChange: function (cmp, event) {
var changeValue = event.getParam("value");
alert(changeValue);
var appEvent = $A.get("e.c:appEvent");
appEvent.setParams({ "message" : changeValue });
appEvent.fire();
}
})
The main component handles the app event in re" style="display: block;" />
2 answers