I am trying to get label value of ui:InputCurrency of Lightning Out component used in Visualforce page. I have three different input fields and I have given same aura:Id reason being I am doing some calculation with Switch statement in the controller. So I am trying to get the label value and use it in Switch case.
I tried component.find("totalvalue").label but it didn't work. What am I doing wrong here?
<aura:component description="ExecutiveSnapshot" controller="ExecSnapshotCalculations">
<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
<aura:attribute name="ExecSS" type="Executive_Snapshot__c" default="{'sobjectType' : 'Executive_Snapshot__c'}"/>
<aura:attribute name="ParentAsset" type="String"/>
<div class="slds-form-element">
<div class="slds-form-element__control" >
<ui:inputCurrency value="{!v.ExecSS.Total_Assets__c}" label="Total Assets ($m)" class="slds-input" labelClass="parentvalue" aura:Id="totalvalue" change="{!c.handleParentCalculation}"/>
</div>
</div>
<div class="slds-form-element">
<div class="slds-form-element__control" >
<ui:inputCurrency value="{!v.ExecSS.Total_Revenue__c}" label="Total Revenue ($m)" class="slds-input" labelClass="parentvalue" aura:Id="totalvalue" change="{!c.handleParentCalculation}"/>
</div>
</div>
Best Answer
The syntax you're looking for is
.get('v.label');
However, keep in mind that if there are multiple components with the sameaura:id
, you will get an array of components when you docomponent.find('totalvalue')
. To get the labels you can loop through them like so: