I'm new in playframework 2 and I would like to iterate a map in the template, I'm using java for the moment :-) Can anybody, please, write a example ? My map is like :
Map<Integer,MyObject>
Thanks in advance
In a Play 2 template, you can iterate on a map using this syntax :
@(myMap: Map[Integer, MyObject])
@for((key, value) <- myMap){
@key - @value
}
Thank a lot for your answer @mguillermin. I found other thing that can help somebody, to use the current index in the loop :
@for(((key, value), currentIndex) <- myMap.zipWithIndex) {
@key - @value - @currentIndex
}
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