5

I am using <aura:iteration> to generate a datatable. But I am continuously getting the error:

aura/Select_List_For_Message/Select_List_For_Message.cmp -- Error: unexpected token: a left angle bracket at column 1 of expression: lt['list_name'] (line N/A column N/A)

Below is the code snippet I am getting the error. Really not sure what is being wrong:

Attribute definition:

<aura:attribue name="lists" type="Send_Email_Controller.List_Helper[]"/>

Table:

    <table class="slds-table slds-table--bordered slds-table--cell-buffer">
        <thead>
            <tr class="slds-text-title--caps">
                <th scope="col">
                    <div class="slds-truncate">Send</div>
                </th>
                ...
            </tr>
        </thead>
        <tbody>
            <aura:iteration items="{!v.lists}" var="lt">
                <tr>
                    <td>
                        <ui:inputCheckbox value="{!lt.isSend}"/>
                    </td>
                    <td>
                        <div class="slds-truncate">{!lt['list_name']}</div>
                    </td>

As you can see here, I have already tried {!lt.isSend} and lt['list_name'] ways here. But neither one worked for me.

The answer should be something simple. But I just can't figure out.

Edit

List_helper is a wrapper class defined inside original VF page controller, which is also my lightning component server side controller now. The definition is as below:

public class Send_Email_Controller 
{
    //...
    public class List_Helper
    {
        public String list_name {get; set;}
        public String folder_name {get; set;}
        public Boolean isSend {get; set;}
        public Boolean unsent {get; set;}
        public Decimal v6_id {get; set;}

        public List_Helper()
        {
            isSend = false;
            unsent = false;
        }
    }
}
10
  • Can you please check the spelling of aura:attribue Nov 4, 2016 at 3:34
  • @SantanuBoral You are right. I spelled aura:attribute wrong. But after I fixed it, I am still seeing the same error though.
    – Lance Shi
    Nov 4, 2016 at 3:37
  • @LanceShi What's the definition of List_Helper?
    – sfdcfox
    Nov 4, 2016 at 3:51
  • @sfdcfox I edited my answer and put the code in.
    – Lance Shi
    Nov 4, 2016 at 3:55
  • 1
    @LanceShi Ah. Literally the name lt... possibly reserved? I usually recommend more descriptive variables anyways, but this was definitely good to know.
    – sfdcfox
    Nov 4, 2016 at 4:04

1 Answer 1

7

You can only reference the object property using dot notation only in Lightning Component.

Looks like using var="lt", Lightning component compiles it as <(left angle bracket), so change the var to something else : var="list".

 <aura:iteration items="{!v.lists}" var="list">
       <div>{!list['list_name']}</div> // not supported
       <div>{!list.list_name}</div> // supported
 <aura:iteration>
6
  • 1
    [] is for static index access on an array.
    – sfdcfox
    Nov 4, 2016 at 3:49
  • Thank you for this. But actually I tried both ways. And neither one works for me.
    – Lance Shi
    Nov 4, 2016 at 3:49
  • @LanceShi are you still getting the same error?
    – Praveen
    Nov 4, 2016 at 3:55
  • Yes, I am still getting the same error.
    – Lance Shi
    Nov 4, 2016 at 3:56
  • @LanceShi I was able to reproduce the error, change var="lt" to something else like var="list"
    – Praveen
    Nov 4, 2016 at 4:01

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .