The change method is called when the value in one of the attribute changes.
As an Example If I am having an attribute " Anyname", on change of attribute "Anyname" if I want to call javascript method I can do this as:
Syntax:
Step 1: Build a lightning component.
Step 2: Build a javascript controller.
Note: Whenever we change the value in the input box "enter text", an alert "Value change noticed" will popup.
As an Example If I am having an attribute " Anyname", on change of attribute "Anyname" if I want to call javascript method I can do this as:
Syntax:
<aura:attribute name="Anyname" type="String" />
<aura:handler name="change" value="{!v.Anyname}" action="{!c.doinit}"/>
Step 1: Build a lightning component.
<aura:component >
<aura:attribute name="Anyname" type="String" default="text1" />
<aura:handler name="change" value="{!v.Anyname}" action="{!c.doinit1}"/>
<lightning:input name="enter text" value="{!v.Anyname}"/>
</aura:component>
({
doinit1: function(component,event,helper){
alert("Value change noticed");
}
})
Note: Whenever we change the value in the input box "enter text", an alert "Value change noticed" will popup.
Nice simple explanation
ReplyDelete