Hri*_*lov 0 scala playframework
我试图在playframework视图中迭代,但现在没有成功.我有以下结构:
@if(list != null) {
for(a <- 0 to list.size()/5)
{
// some html, where I want to get the value of a
for(b <- a*5 to a*5+5) // here I want to use the a value again
{
some html
}
}
Run Code Online (Sandbox Code Playgroud)
所以我的问题是如何获取循环的当前索引,以便我能够使用它.
你应该把它组合成一个for循环:
@if(list != null) {
@for{a <- 0 to list.size()/5
b <- a*5 to a*5+5}
yield html
}
}
Run Code Online (Sandbox Code Playgroud)
并使用选项而不是null检查.您还可以使用map函数来转换列表.请参阅Play文档中的详细信息 - http://www.playframework.com/documentation/2.0/ScalaTemplates
| 归档时间: |
|
| 查看次数: |
3142 次 |
| 最近记录: |