function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Aman nemaAman nema 

Counter inside aura:iterator

Hi All,

I want to use counter inside aura: iterator. Like below

<aura:attribute name="counter" type="integer" default="0"/>

<aura:iteration items="{!v.futureInteractions}" var="Interaction">
  <aura:if istrue="{!v.counter =0 && Interaction.isFutre}">
      Futre interaction
     <aura:set attribute="counter" value="1" />
  </aura:if>
</aura:iteration>

Can anyone help me how can i change counter value inside iterator???
Best Answer chosen by Aman nema
sfdcMonkey.comsfdcMonkey.com
calculate and set counter attribute in javaScript controlller/helper not in Lightning component 
i.e
doInit : function(component, event, helper) {
	  var futureInteractions = component.get("v.futureInteractions");
      var counter = component.get("v.counter");
       var finalCount = 0;  
        for(var i = 0; i < futureInteractions.length; i++){
            if(futureInteractions[i].isFutre && counter == 0){
               finalCount++; 
            }
        }
        
     component.set("v.counter" , finalCount);   
    },

inside aura:iteration only itrate values 


Thanks, let us know if it helps you
sfdcMonkey.com