play-framework-twirl-template
1. I have multiple questions in variable list. 2. Need to declare variable outside for loop and use as counter variable in for loop. like @var count=0; 2. I iterate list on scala.html file @for(d <-list){ count++ or count+=1;// getting error } 3. through this loop need to print number with questions like Sr.No QuestionName Option.. 1 ABC A.. 2 ZYX D..
您应该在scala集合上使用zipWithIndex功能(scala文档中的更多信息:here;
大量使用:
@for((value, index) <- list.zipWithIndex){ @* Print value *@ @value @* Print index - first index will be 0 *@ @index @* Print index + 1 *@ @{index+1} }