I have a lightning:buttonIcon
, on click of which I want it to be change to buttonIcon of some other type and its onclick action method should also change.
Markup:
<lightning:buttonIcon aura:id="downIcon"
iconName="utility:down"
variant="bare"
alternativeText="Settings"
iconClass="dark"
class="slds-button slds-input__icon slds-text-color--default"
onclick="{!c.openDropdown}"/>
Controller:
openDropdown: function(component, event, helper){
var iconID=component.find('downIcon');
iconID.set('v.iconName', 'utility:close'); //Working
iconID.set('v.onclick',component.getReference('c.showDefaultValue')); //Not working
}
Here i have used the logic for dynamically giving name of method to component as mentioned here: https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/js_cb_dynamic_cmp_async.htm
When I click the buttonIcon, it is giving me error :
Assertion Failed!: Unable to set value for key 'c.openDropdown'. Value provider does not implement 'set(key, value)'. : false
As I can change the "iconName" property of lightning:buttonIcon from controller, how can I similarly change method name of "onclick" property?