You need to sign in to do that
Don't have an account?
komal pulani 2
Requirement is to change the variable value inside aura:if
Hi, I have a requirement where i want to change the value of attribute insode the aura:if.
I want to set the value of disableActivityDate to True if BranchValue!=null .Here is my code:
<aura:attribute name="disableActivityDate" type="String" default="true"/>
<aura:If isTrue="{!v.BranchValue!=null}">
<lightning:inputField fieldName="Activity_Date__c" aura:id="dateField" onchange="{!c.resetActivityTimeSelection}" disabled="{!v.disableActivityDate}"/>
</lightning:layoutItem>
</aura:If>
I want to set the value of disableActivityDate to True if BranchValue!=null .Here is my code:
<aura:attribute name="disableActivityDate" type="String" default="true"/>
<aura:If isTrue="{!v.BranchValue!=null}">
<lightning:inputField fieldName="Activity_Date__c" aura:id="dateField" onchange="{!c.resetActivityTimeSelection}" disabled="{!v.disableActivityDate}"/>
</lightning:layoutItem>
</aura:If>
Please try below code and let me know if this works for you. If still need modifications do let me know.
Component :
Controller:
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks,
Ajay Dubedi
Try this.
Component:
Controller:
I went through the code of yours and found that you have taken the type of the attribute as a string and you are trying to use it as boolean which is causing the problem. Please change your type from "String" to "Boolean" as the disabled attribute of the input field works only with the boolean value.
Please change your attribute :
<aura:attribute name="disableActivityDate" type="String" default="true"/>
to:
<aura:attribute name="disableActivityDate" type="Boolean" default="true"/>
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks and Regards,
Deepali Kulshrestha.