+ Start a Discussion
kevin van Turennoutkevin van Turennout 

Aura iterate to list with check if greather than today?

I have a list with a date field for each record and i have a aura iterate to the list to show for each record sliders.
Now i only want to show sliders for the records with date greather than today.

What is the best way to do it? I try with aura:if to check list.date with a today attribute create in my controller with var today = new date();

but it did'nt work
Neha AggrawalNeha Aggrawal
Hi Kevin,

Best way I feel would be to do this in the JS controller. Somthing like below probably:
component.set('v.Contacts', actionResult.getReturnValue()); // Got the data from Apex controller
var fullList = component.get("v.Contacts");
  var todayDate = new Date(); //will get current date
  for(var item of fullList){
if(item.checkdate<todayDate)
{
final_arr.push(item);
}
}

Hope this helps.
Thanks and Regards, 
Neha
www.initaura.com - Everything Salesforce (https://www.initaura.com)
kevin van Turennoutkevin van Turennout
Hi Neha,

Thank you for your answer,
I see that I had forgotten something in my question. Everfy record has a total amount and in the and i want to sum all te total amounts to show it in my component. I need all records that are retrieved in my list
Neha AggrawalNeha Aggrawal
Hi Kevin,

You can keep your original records in another array. And one array you can keep your filtered records. Use and assign which ever array you require in your component.

Does that make sense ?
Thanks,
Neha