0

Here is part of my code which fails :

<aura:iteration items="{!v.layout}" var="item">
        <aura:if istrue="{!(item.elementType == 'HEADER') ? true : false}">

I tried rewriting this like this also :

 <aura:iteration items="{!v.layout}" var="item">
        <aura:if istrue="{!item.elementType == 'HEADER'}">

But i'm obtaining the same error. Seems like it don't like the item.elementType, where elementType is an attribute of the item instance.

1
  • 1
    Did you try this: <aura:if istrue="{!item.elementType == 'HEADER' ? 'true' : 'false'}">
    – Ashwani
    Aug 2, 2016 at 8:16

2 Answers 2

2

Why don´t you add directly a boolean variable to your attribute?

<aura:iteration items="{!v.layout}" var="item">
        <aura:if isTrue="{!item.isHeader}">}

Anyway the code your provided should work, I have some similar logic working in my org.

An other comment I want to add is that you should not add an aura:if as an immediate child of aura:iteration, because doing this will cause you unexpected issues due to a known bug in components.

1
<aura:iteration items="{!v.layout}" var="item">
         <aura:if istrue="{!item.elementType == 'HEADER' ? 'true' : 'false'}">

Hope this would work.

2
  • no it doesn't work. I think that it cannot get access to the elementType attribute , because layout is not defined initially as an array of which type of object. <aura:attribute name="layout" type="list" default="[]" description="The json template in the form of a map to generate the layout" />
    – vanessen
    Aug 2, 2016 at 10:35
  • Please provide some description also.
    – Mr.Frodo
    Aug 2, 2016 at 15:04

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.