I have an aura iteration using dynamic fields in this code snippet.

<aura:iteration items="{!v.qResults}" var="q">
            <li id="{!q.Id}" class="slds-dropdown__item" role="menuitem option" onclick="{!c.redirectRec}">

                <aura:iteration items="{!v.queriedQuickSearchFieldsAPI}" var="quickSearchField"  >

                <c:Generic_Variable_Field_Component dynamicObjectN="{!q}" fieldName="{!quickSearchField}" />,


it displays the proper fields, but i want to know if i can format it with commas, when this code is ran in salesforce it gives the format


but i want to stop adding the comma on field 2.

something like this.


I don't know if this has to do with the controller, since im just passing values all over and since it is dynamic, manipulating the values on other controllers can affect the other component using this value as well.

thanks for the help!


You can use aura:if for this

<aura:iteration items="{!v.queriedQuickSearchFieldsAPI}" var="quickSearchField"  indexVar="index">
  <c:Generic_Variable_Field_Component dynamicObjectN="{!q}" fieldName="{!quickSearchField}" />
 <aura:if isTrue="{!index < listSize? true : false}">

Here listSize is your result array length .This can be from an attribute populated in your JS controller

Also use caution while doing this as too much aura:if can impact performance as documented here

The other alternative would be to do this inside the JS itself and rearrange the fields in a single attribute

  • it works thank you! but im kind of scared about what you said about the performance issues on aura:if, i'll raise this to my client. <aura:if isTrue="{!index < listSize? true : false}"> can you explain what the true:false is doing in the condition? i removed it (because it caused errors) and everything works fine as well.
    – nyor
    Apr 20 '16 at 6:01
  • Ya I thought I should add true and false explicitly but looks like since we needed boolean it's OK .It's conditional expression syntax . Apr 20 '16 at 6:03

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.