In the javascript controller of my lightning component, I need to call an apex method and pass it a map as parameter.
I have issues when setting the value in the map, in the javascript.
Now I have something like this in the javascript controller :
handleGetResult : function(component, event, helper) {
var lines = component.get('v.listLines');
console.log('lines : ');
console.log(lines);
//send a map as a parameter of the apex method
var mapLines = {};
for(var key in lines.keys()){
mapLines[key] = lines.get(key);
}
console.log('mapLines : ');
console.log(mapLines);
//call apex method that construct the query
var action = component.get('c.manageFilters');
action.setParams({
lines : mapLines
});
action.setCallback(this, function(response){
var state = response.getState();
if (state === "SUCCESS"){
}
});
$A.enqueueAction(action);
}
But here mapLines
is null even if I put many item in it via the lightning component. lines
is not null and contains all the items.
I don't know how to create the map in javascript.
The apex method so far :
@AuraEnabled
public static String manageFilters(Map<String, Object> lines){
System.debug('### lines : ' + lines);
return null;
}