We are now starting moving our application to Lightning by re-writing it. We are facing some problems during the process and the one which is now blocking us is the following.

We have one component called timesheetGrid.cmp which has an attribute called currentTimesheetLines I'm correctly loading and render data from it on the controller. But I need to pass this attribute from this one timesheetGridRenderTSEColumnSummaryCell passing it like that.

<aura:component description="timesheetGrid" implements="flexipage:availableForAllPageTypes,force:hasRecordId" access="global" controller="LgtTimesheetCtrl">
  <aura:attribute name="currentTimesheetLines" type="TimesheetCode__c[]" 
<aura:iteration items="{!v.currentTimesheetLines}" var="timesheetLine" indexVar="i">
<c:timesheetGridRenderTSEColumnSummaryCell timesheetLines="{!v.currentTimesheetLines}"/>


The problem is even when I can iterate through and render data from it. On the timesheetGridRenderTSEColumnSummaryCell controller when I read it I can get it, it's always an empty array.

Can someone help with this issue?

This happens just with this type of "array of objects" params, with any other doesn't.


Arrays have been always tricky, I found a long route out by Stringifying the response and pass it to the second component controller and the deserializing into an object again.



<aura:application >
<c:passarraycomp1 ></c:passarraycomp1>

comp 1:

<aura:component controller="passtoarraycontroller" implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,force:lightningQuickAction" access="global" >
    <aura:attribute name="arraytopass" type="String"/>
    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
    <c:passarraycomp2 arrayofaccounts="{!v.arraytopass}"/>

comp 1 controller:

    doInit : function(component, event, helper) {
        var action = component.get("c.serverEcho");
        action.setCallback(this, function(response) {
            var state = response.getState();
            if (state === "SUCCESS") {
            else if (state === "INCOMPLETE") {
                // do something
                else if (state === "ERROR") {
                    var errors = response.getError();
                    if (errors) {
                        if (errors[0] && errors[0].message) {
                            console.log("Error message: " + 
                    } else {
                        console.log("Unknown error");



<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,force:lightningQuickAction" access="global" >
    <aura:attribute name="arrayofaccounts" type="String"/>
    <lightning:button label="fetchvalueofsecondcomponent" onclick="{!c.getarrayofaccs}"/>

comp2 controller:

    getarrayofaccs : function(component, event, helper) {
        console.log('#####'+ component.get("v.arrayofaccounts"));
        //use JSON.deserialize to convert this back to an array.

Server side controller:

public class passtoarraycontroller {

    public static list<account> serverEcho(){
        return [select id,name from account limit 10];

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.