0

I have an iteration which reproduces a list on a lightning page. I want to make this iteration variable based on 2 lists. How do I make the list (items) variable based on IF condition? Or do I need to place the whole iteration twice in an if condition?

Something similar to:

  <aura:if isTrue="{!v.opleidingenListfilteredByDate == null}"> 
              <aura:variable var="Opl" value="{!v.opleidingenList}"/>
        </aura:if>
         <aura:if isTrue="{!v.opleidingenListfilteredByDate != null}"> 
             <aura:variable var="Opl" value="{!v.opleidingenListfilteredByDate}"/>
        </aura:if>  
        <aura:iteration items="Opl" var="opleiding">
...
</aura:iteration>
2
  • You mean "aura:attribute", right?
    – sfdcfox
    Jun 28, 2018 at 6:46
  • I think you've somehow confused Visualforce and Lightning. They don't really share much of the same syntax, and it's probably not advantageous to try and perform a direct port.
    – sfdcfox
    Jun 28, 2018 at 6:51

1 Answer 1

2

You should be able to:

<aura:iteration items="{!if(empty(v.opleidingenListfilteredByDate),v.opleidingenList,v.opleidingenListfilteredByDate)}" var="opleiding">

Realistically, though, it'd be a lot easier to just set the appropriate values in your controller/helper rather than doing something like this.

1
  • The first list is created by checkboxfilter the second is a datefilter over the checkboxfilter, I want to be able to maintain those 2 separate so thought this is an easy solution. Thanks it works!
    – Thomas
    Jun 28, 2018 at 7:39

You must log in to answer this question.

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