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 isTrue="{!v.opleidingenListfilteredByDate != null}"> 
             <aura:variable var="Opl" value="{!v.opleidingenListfilteredByDate}"/>
        <aura:iteration items="Opl" var="opleiding">
  • You mean "aura:attribute", right? – sfdcfox Jun 28 '18 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 '18 at 6:51

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.

| improve this answer | |
  • 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 '18 at 7:39

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.