Skip to main content
added 381 characters in body
Source Link
tom_12321
  • 191
  • 7
  • 16

I would like to pass an array of objects from my js file to an aura attribute. I know the list contains values and is correct before I pass it to the aura component but the list is empty when I log that attribute to the console.

Helper method:

//convert map into list of objects for Aura
                var objects = [];
                for(var rawLineItem in result.rawLineItemToContactIdList) {
                    objects.push({key:rawLineItem, value:result.rawLineItemToContactIdList[rawLineItem]});
                    console.log('objects: ' + JSON.stringify(objects));
                }
                component.set("v.objectList", objects);

Aura attribute:

<aura:attribute name="objectList" type="List" />

EDIT: Then I log the objectList varible to the console:

Aura:

<button class="slds-button slds-button_brand" onclick="{!c.showDupes}" >Log</button>

Helper:

showDupes: function(component, event, helper) {
        var objectList = component.get("v.objectList");

        console.log('objectList: ' + JSON.stringify(objectList));
    },

I would like to pass an array of objects from my js file to an aura attribute. I know the list contains values and is correct before I pass it to the aura component but the list is empty when I log that attribute to the console.

Helper method:

//convert map into list of objects for Aura
                var objects = [];
                for(var rawLineItem in result.rawLineItemToContactIdList) {
                    objects.push({key:rawLineItem, value:result.rawLineItemToContactIdList[rawLineItem]});
                    console.log('objects: ' + JSON.stringify(objects));
                }
                component.set("v.objectList", objects);

Aura attribute:

<aura:attribute name="objectList" type="List" />

I would like to pass an array of objects from my js file to an aura attribute. I know the list contains values and is correct before I pass it to the aura component but the list is empty when I log that attribute to the console.

Helper method:

//convert map into list of objects for Aura
                var objects = [];
                for(var rawLineItem in result.rawLineItemToContactIdList) {
                    objects.push({key:rawLineItem, value:result.rawLineItemToContactIdList[rawLineItem]});
                    console.log('objects: ' + JSON.stringify(objects));
                }
                component.set("v.objectList", objects);

Aura attribute:

<aura:attribute name="objectList" type="List" />

EDIT: Then I log the objectList varible to the console:

Aura:

<button class="slds-button slds-button_brand" onclick="{!c.showDupes}" >Log</button>

Helper:

showDupes: function(component, event, helper) {
        var objectList = component.get("v.objectList");

        console.log('objectList: ' + JSON.stringify(objectList));
    },
Source Link
tom_12321
  • 191
  • 7
  • 16

Aura attribute of type List not accepting an array of objects

I would like to pass an array of objects from my js file to an aura attribute. I know the list contains values and is correct before I pass it to the aura component but the list is empty when I log that attribute to the console.

Helper method:

//convert map into list of objects for Aura
                var objects = [];
                for(var rawLineItem in result.rawLineItemToContactIdList) {
                    objects.push({key:rawLineItem, value:result.rawLineItemToContactIdList[rawLineItem]});
                    console.log('objects: ' + JSON.stringify(objects));
                }
                component.set("v.objectList", objects);

Aura attribute:

<aura:attribute name="objectList" type="List" />