Amit, I want to accesss one method variable or list in some other method in (server side). Second method i want to access first method query data instead of writing same query in second method. is it possible to access?
({
handleClick1 : function (component, event, helper) {
var action = component.get("c.method1");
action.setCallback(this, function(a) {
component.set("v.str", a.getReturnValue());
});
$A.enqueueAction(action);
},
handleClick2 : function (component, event, helper) {
var action = component.get("c.method2");
action.setCallback(this, function(a) {
component.set("v.str", a.getReturnValue());
});
$A.enqueueAction(action);
}
})
Another way you can do it .. move the entire logic into the service class .. in service class you can refer the same variable from the different methods .. you no need to use static methods in service class ( use singleton pattern or any best practices )
Hi, I used the Raj and Srikanth method to share the list with other method but i have no success, is it possible can you please share the code. My case is that i am creating the list in one method and then i want to use the same list with other method, how can i acheive that. Please share your expertise. Thanks
Here the complete code
Apex class
Component
Another way you can do it .. move the entire logic into the service class .. in service class you can refer the same variable from the different methods .. you no need to use static methods in service class ( use singleton pattern or any best practices )
If you are asking in the Apex class, then You can call AuraEnabled methods same as normal methods.
eg. Please mark as solved and also best answer if it will solve your problem.
Thanks.
I used the Raj and Srikanth method to share the list with other method but i have no success, is it possible can you please share the code.
My case is that i am creating the list in one method and then i want to use the same list with other method, how can i acheive that.
Please share your expertise.
Thanks