[SalesForce] Lightning aura:attribute with custom List type returns error

The Lightning developer guide says that an aura:attribute can contain a List of custom apex type objects, like this:

<aura:attribute name="colorPalette" type="List<docSampleNamespace.Color>" />

However, when I try this, I get this error message:

Message: The value of attribute "type" associated with an element type "null" must not contain the '<' character.: Source

Is this just not implemented yet in the dev preview, or am I doing something wrong?

Best Answer

The problem is XML does not allow the use of unescaped < or > characters. In Apex (which is where Lightning Components gets its type system) arrays and lists are equivalent. We typically use array notation in attribute defs because you do not have to &lt; and &gt; encode the []. Try this instead:

<aura:attribute name="colorPalette" type="docSampleNamespace.Color[]"/>
Related Topic