Problem with each loop in Edge


#1

{{product.group}} // here product.group is known = 10
@each(category in categories)
{{category.id}}
{{product.group}} // Here product.id is no longer known = undefined ???
@if(product.group === category.id) // So this does not work ???
{{category.id}}
@endif
@endeach

Is this a bug or is this normal ?
Doing such things in laravel blade works like a charm ?

thanks


#2

how about giving @endif at the if line?

{{product.group}} // Here product.id is no longer known = undefined ???

and i dont understand what is the meaning of this line. cuz i’ve tried it in my code and it works perfectly fine. mind sharing some code on your controller?


#3

Problem Solved

The each was already in a Each loop (it was a nested loop !)

Then to reach the product.group we need to use : $parent.product.group

thanks.