0

I need to Display a Certain Component Based on whether the item in my list has a field or not. I am trying to use != Null but right now it skips the first portion of the If statement regardless of if the field is null or not. Code and examples below:

the List seems to be read in properly:

Console Log:

0: {article: {…}} 1: {article: {…}} 2: {article: {…}} 3: {event: {…}} 4: {article: {…}} 5: {event: {…}}

Code for Aura:Iteration and Aura:If

   <aura:iteration items="{!v.listOfWrappers}" var="wrapper" end="10">          
    <aura:if isTrue="{!not(empty(wrapper.Event_Type_Filter__c))}"> 
        <section id="" class="container" onclick="">
            <div class="event-image" style="padding: 16px;"><img style="height: 100%;" src="{!$Resource.CalendarIcon}"/></div> 
            <div class="event-detail">
                <div class="event-title">{!wrapper.Name}</div>
                <div class="event-date">{!wrapper.StartDate__C}</div>
                <div class="event-location">{!wrapper.Location__C}</div>
                <div class="event-products">{!wrapper.Product_Filter__c}</div>
                <div class="event-type">{!wrapper.Event_Type_Filter__c}</div>
            </div>
        </section>
    <aura:set attribute="else">
        <section id="" class="container" onclick="">
            <div class="event-image" style="padding: 16px;"><img style="height: 100%;" src="{!$Resource.ArticleIcon}"/></div> 
            <div class="event-detail">
                <div class="article-title">{!wrapper.Title__c}</div>
                <div class="article-description">{!wrapper.Summary}</div>
            </div>
        </section>
    </aura:set>
    </aura:if> 
   </aura:iteration>

What is being displayed currently is only the else portion of the Aura:if. Furthermore the data for the item in the list is not being displayed either:

enter image description here

0

Data Display issue: My issue was that I was referencing a list comprised of two lists so instead of {!wrapper.Name} I needed {!wrapper.event.Name}

Aura:Iteration issue:

Once I realized the first part I was able to use <aura:if isTrue="{!wrapper.event}"> to check which object type the next value in my list was, and then create the appropriate component to match.

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.