Question

Is there a way to add a for loop when using spark view engine ? I'm trying to add pagination support to my view and trying to loop through and add list entries listed below:

<li><a href="#">1</a></li>
<li><a href="#">2</a></li>

Unfortunately all I can find are examples to use foreach. Is there way to do this in spark ?

Was it helpful?

Solution 2

No direct way, but several indirect methods are listed in this page:

https://groups.google.com/forum/#!searchin/spark-dev/for$20loop/spark-dev/vfUUg2KUFk4/yqJ4iRUNYC4J

OTHER TIPS

I guess the only thing a for loop would give you over a foreach is the index of the current item (well, that and obviously being able to control the size of iteration increments), but in Spark we provide the index of the current item so that you can use it like this:

<for each="var thingy in Model.Thingies">
  <div>Item ${thingyIndex} of ${thingyCount}</div>
</for>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top