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 ?

Était-ce utile?

La 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

Autres conseils

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>
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top