[SalesForce] Lightning calling helper function returns not a function in init

I think this is something silly I'm missing, but please tell me what's wrong..

Controller.js

({
    doInit: function(component, helper, event) {
        helper.runSetup();
}
})

Helper.Js

({
  runSetup : function() {
    console.log('test');
  }
})

and I'm getting error as:

Action failed: c:IB_Preferences_UI_Sector$controller$doInit [helper.runSetup is not a function]]

every single time…

This is really frustrating, because I've done that before on other projects and it was fine. And suddenly it stopped..

Any ideas?

Best Answer

your Controller Should be

({
    doInit: function(component, event, helper) {
        helper.runSetup();
}
})

Actually you have interchanged the position of attributes passed.

In your controller attribute value should be in this order. But in your helper you can decide in whatever order you want to transfer the attributes.

Related Topic