Any equivalent of apex:variable in Lightning Components?

In Visualforce apex:variable can be used to avoid the repetition of a Visualforce expression.

I have a collection returned from an @AuraEnabled method for which I want to do the same sort of thing that apex:variable does:

<aura:iteration var="item" items="{! v.items }">
    <!-- aura:variable does not exist: is there a way to do this in Lightning? -->
    <aura:variable var="sob" value="{! item.reference.sobReference }"/>
        <td>{! sob.Name }</td>
        <td>{! sob.Birthdate }</td>

Is there a way to do this in Lightning Components?



You can use an attribute in the lightning component, and then set the value in your controller.



Edit: It seems like you’re just trying to alias an attribute you already have access to.

<aura:iteration var="item" items="{! v.items }">
    <td>{! item.reference.sobReference.Name }</td>
    <td>{! item.reference.sobReference.Birthdate }</td>


Source : Link , Question Author : Keith C , Answer Author : Ross Bassett

Leave a Comment