If I have two functions foo()
and bar()
in my Lightning component controller, how can I call one function directly from another function, without having to queue it up through $A
?
Here's a sample controller setup:
({
bar : function(component, event, helper) {
// Do something cool
},
foo : function(component, event, helper) {
// How do I call bar() from here?
}
})
Best Answer
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:
Obviously don't do that! :)