+ Start a Discussion
Angel ZAngel Z 

detect changed value of attribute type Aura.Component[]

Hi All,

I have an attribute:
<aura:attribute name="changeAccountStatus" type="Aura.Component[]" required="false"/>

and a handler:
 
<aura:handler name="change" value="{!v.changeAccountStatus}" action="{!c.statusChanged}"/>

I want to detect when the value has been updated:
 
statusChanged : function(cmp, event, helper) {

      console.log("old value: " + event.getParam("oldValue"));
      console.log("current value: " + event.getParam("value"));

}
However, it never fires the statusChanged method.

Any help would be greatly appreciated.

Thanks,
Angel

 
Ajay K DubediAjay K Dubedi
Hi Angel,

Use bellow js helper code for check your component value has set or not:
 
statusChanged : function(cmp, event, helper) {

    let changeAccountStatus = cmp.get('v.changeAccountStatus');
    if(changeAccountStatus != null){
        console.log('attribute changeAccountStatus value has been set');
    }
}

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks and Regards,
Ajay Dubedi
www.ajaydubedi.com