You need to sign in to do that
Don't have an account?

Using arithmetic comparison in if:true statement in Lightning web component
Hi Team,
I have for-each loop in my LWC component. And I want to check below condition inside the loop.
But this is not working. I am not sure how could I use the arithmetic comparison in HTML file of LWC. Could anyone please help me to resolve this?
I have for-each loop in my LWC component. And I want to check below condition inside the loop.
<template for:each={object.MonthListBefore} for:item="month" > <template if:true={month == 'Jan'}> <li key={object.Id} class="year">{object.currentYear}</li> </template> </template>
But this is not working. I am not sure how could I use the arithmetic comparison in HTML file of LWC. Could anyone please help me to resolve this?
All Answers
you can use something below,
in your JS controller,
Hope this will give you some idea.
Thanks
karthik
Here I have to check month == 'Jan'. "month" is coming from for each loop. It is dynamic.
Thank you. I will try and let you know
Thank You. Your solution is working fine !