I would like to know if it is possible to evaluate the expresion not comparing to a constant but instead to another variable, like the iteration variable from aura:iteration.

I want to evaluate the expression for every iteration. This is my code

<aura:iteration items="{!v.tiles}" var="tile" end="7">
   <aura:if isTrue="{!v.tileName == tile}">

       <!-- content renders if true --> 

   <aura:set attribute="else">

       <!-- content renders if false -->

I dont know if it is unsupported or if I am making a syntax error but it does not work.

Thank you.

  • 1
    its not clear what you are trying to do, like compare !tile.name == tile.someOtherName ? – glls Sep 10 '18 at 2:27
  • 1
    you probably want to check Expression Functions Reference – glls Sep 10 '18 at 2:30
  • Share the type of tiles, tileName attributes. – itzmukeshy7 Sep 10 '18 at 2:33

Your problem is elsewhere in code you've omitted. Here's a self-contained example of comparing the current iterator to a specified value:

<aura:application >
    <aura:attribute name="items" type="List" default="[1,2,3]" />
    <aura:attribute name="current" type="Integer" default="2" />

    <aura:iteration items="{!v.items}" var="item">
        <aura:if isTrue="{!v.current == item}">
            <div>Current: {!item}</div>
            <aura:set attribute="else">
                <div>Not Current: {!item}</div>


Not Current: 1
Current: 2
Not Current: 3
  • You understood my point and your example has showed me that compring can be possible. I have problem with my v.current variable. It is calculated in the js controller and I can debug it but I dont know how to debug it in the component. I will try lightning inspector and use eq instead of == for comparing. – ElkCor Sep 10 '18 at 3:30
  • @ElkCor I suspect maybe you didn't store the value back into the data set? You can't use an evaluated value without storing it back in to the data. – sfdcfox Sep 10 '18 at 3:41

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.