Sample apex class
Public class SampleApexCls{
@AuraEnabled
public static List<String> testSmapleMethod(){
//some code here
Return ListofValues;
}
@AuraEnabled
public static Map<Id,String> testSmapleMethod2(){
//some code here
Return map;
}
}
({
getSmapleData :function(component){
var action=component.get("c.testSmapleMethod");
action.setCallback(this,function(response){
var returnValue=response.getReturnValue();
this.getSmapleData1 (component) // I know how to call the funcation
// Whant to get "returnValue2" results in this method.
});
},
getSmapleData1 :function(component){
var action=component.get("c.testSmapleMethod2");
action.setCallback(this,function(response){
var returnValue2=response.getReturnValue();
});
}
})
how do I access "returnValue2" in "getSmapleData" funcation.
can "getSmapleData1" return some value.
can any please help to get the one funcation values or varaible to display in other funcation like how we do in general apex class
Hi Aruna, I don't think we have an option to call one method in another method within the controller, whereas we can do that inside the helper bundle. Find the working code and modify based on your requirements Component: <aura:component implements="flexipage:availableForAllPageTypes">
<aura:handler name='init' value='{!this}' action='{!c.doInit}' />
</aura:component>
Controller js file:
({
doInit : function(component, event, helper) {
helper.getSampleData1(component, event, helper);
},
})
Helper js file:
Output in the browser console:({
getSampleData : function(returnValue2) {
console.log('inside getSampleData');
console.log(returnValue2);
},
getSampleData1 : function(component, event, helper) {
var returnValue2 = "My custom test value!";
helper.getSampleData(returnValue2);
},
})
Test this and share the results. NaveenTeam codengine.in