Activity Forums Salesforce® Discussions How can we call one controller function from another controller function in Lightning in Salesforce ?

  • How can we call one controller function from another controller function in Lightning in Salesforce ?

    Posted by Kirandeep on February 10, 2020 at 3:25 pm

    How can we call one controller function from another controller function in Lightning in Salesforce ?

    Marziya replied 4 years, 3 months ago 2 Members · 1 Reply
  • 1 Reply
  • Marziya

    Member
    February 10, 2020 at 4:43 pm

    Hii Kirandeep,

    I think that the better approach would be to try to extract whatever it is that you need to call in that controller function into the helper and call the helper. The helpers exist to enable sharing code within a component. Do you have a use case where that wouldn't work?

    Just for fun, inspecting the action object the following would work:

    var action = component.get("c.bar");
    action.$meth$();

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos