As we all know helper methods in Lightning usually have the following signature:

openAffiliationCreateDialog : function(component, event) { ... }

My question here, is it possible to stop passing component around and figure it out from current context (i.e. THIS) right inside helper function?

We have some hierarchy of components which share common logic from basic helper through inheritance. And not all of basic helper methods have component as param. Now we need to add some additional functionality inside those methods "without component" which need to access some component attributes. So I'm wondering if there is a better way instead of going and modifying each helper method execution passing component as a param.

  • I wonder if you could declare it as an attribute and set it using a set attribute ie <aura:attribute name="cmp" type="Object" /> - <aura:set value="{!this}" attribute="cmp"/> Jul 17, 2017 at 8:33

1 Answer 1


I did a wee test and you CAN do this:

Set the component on init:


<aura:handler name="init" value="{!this}" action="{!c.init}" />



init:function(component) {
   thisCmp = component;

getData:function() {
  var testCmp = thisCmp;
  //this is a valid component.

I'm not sure how long this component will remain valid for... Might be a good idea to get the Lightning Team to weigh on on this.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .