+ Start a Discussion
Martha VMartha V 

Lightning Component Framework Specialist - step 4 aura:iteration not working

Hi, my code has passed the step 4 check, but when I try the search by boat type no boats appear on the BoatSearchResults component. I have done some debugging and found that it is not entering into the aura:iteration and can't figure out why. Hopefully someone can help me.

The string "going to AuraIteration" appears on the screen, but nothing else. The variable v.boats contains the right amount of items (I am testing it with Sailboat type and it has 2 items. It also has the right values in each object.

Here is my code: 

<aura:component controller="BoatSearchResults">
    <aura:attribute name="boatTypeId" type="String" />
    <aura:method name="search" description="gets the boatTypeId from BoatSearch component and runs the search"
        <aura:attribute name="boatTypeId" type="String" />
    </aura:method >
    <aura:attribute name="boats" type="Boat__c[]" />
    <lightning:layout multipleRows="true" verticalAlign="center" horizontalAlign="center">
        <aura:if isTrue="{!v.boats.length &gt; 0}">
            going to AuraIteration
            <aura:iteration items="{!v.boats}" var="boatItem">
                <lightning:layoutItem flexibility="grow" class="slds-m-right_small">
                    <h3>calling BoatTile</h3>
                    <c:BoatTile boat="{!boatItem}"/>
            <aura:set attribute="else">
                <lightning:layoutItem class="slds-align_absolute-center" flexibility="auto">
                    <h3>No boats found</h3>

Also, can someone tell me how to post code so it looks like code (lined and with the option to copy, etc)


Raj VakatiRaj Vakati
Refer this link


ajay Duggi(Heptarc)ajay Duggi(Heptarc)
Dear Martha Vance5,
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes" 
                access="global" controller="BoatSearchResults">
    <aura:handler name="init" action="{!c.doSearch}" value="{!this}"/>
    <aura:attribute name="boatTypeId" type="String" />
    <aura:attribute name="boats" type="Boat__c[]" />  
    <!--<aura:method name="search" description="Sample method with parameter">
        <aura:attribute name="boatTypeId" type="String"  />
    <!-- set up the aura:method for search -->
    <aura:method name="search" description="accepts boatTypeId
            and executes search that refreshes the boats attribute">
        <aura:attribute name="boatTypeId" type="Id"/>
    <!-- Display errors, if any -->
    <aura:if isTrue="{!not(empty(v.errorString))}">
        <div class="recordError">
            <ui:message title="Error" severity="error" closable="true">
    <aura:if isTrue="{!not(empty(v.boats))}">
        <lightning:layout multipleRows="true" horizontalAlign="center">
                <aura:iteration items="{!v.boats}" var="boatVar">
                    <lightning:layoutItem flexibility="grow"  class="slds-m-right_small" >   
                        <c:BoatTile boat="{!boatVar}"/>
         <aura:set attribute="else">
            <div class="slds-align_absolute-center">No boats found</div>
Please try code it may helps,
Please let me know if problem solves.
Martha VMartha V

Dear ajay Duggi(Heptarc),

I tried your code, and am still getting the same thing. It is not going into the Aura:iteration :(
Martha VMartha V
I followed the links you supplied and neither of them helped me.
Christan G 4Christan G 4
Hi Martha, I hope you are well. I knew it was a long time since you posted this but I think your issue resides in either the apex method you are using to retrieve the boats or in your javascript client side code. Hopefully, you were able to resolve your issue by now.