-1

I use a

<aura:attribute name="colorPalette" type="List" default="['red', 'green', 'blue']" />

and default values are not assigned to the attribute. The value that the attribute has is always "". Anyone knows what i am doing wrong or if there is a known issue?

  • How are you trying to call that list? – Carlos Naranjo Nov 16 at 19:32
2

I tried your exact code and it worked for me, both from markup and init handler in javascript

<aura:application >
<aura:attribute name="colorPalette" type="List" default="['red', 'green', 'blue']" />
<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>  
<aura:iteration items="{!v.colorPalette}" var="item">
        <p>{!item}</p>
</aura:iteration>
</aura:application>

Controller code:

({
    doInit : function(component, event, helper) {
    alert(component.get('v.colorPalette')); 
    }
})

UI Screenshot:

enter image description here

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.