Hey. How can i have a variable in each tag to be an iterator (for example, first time run cycle takes value=1, second time value=2, and so on..
The status attribute is what you are looking for. See below:
<g:each collection=${books} var="abook" status="i">
${i}
</g:each>
if you call ${i} inside the each tag it will return the current iteration count.
Assuming the books collection contains 5 books, the output will be:
0
1
2
3
4
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With