4

How would I go about writing a while loop, doing the equiv of

while (x--) {
  <li> foo {{x}} </li>
}

with a "microsyntax" similar to *ngFor but for looping with an incrementer or decrementer rather than over an object. So if component has x = 5. And I want

<li> foo 5 </li>
<li> foo 4 </li>
<li> foo 3 </li>
<li> foo 2 </li>
<li> foo 1 </li>

Or the like. Template Toolkit does this with WHILE. I'm looking for that kind of functionality. So does jade/Pugs.

Evan Carroll
  • 78,363
  • 46
  • 261
  • 468
  • @AniruddhaDas not afaik. Feel free to show me how, if it is. ngFor loops over iterators as far as I can see. – Evan Carroll Sep 08 '17 at 20:28
  • @AniruddhaDas that's assuming foo's is an iterator, what it it's the number `5`? – Evan Carroll Sep 08 '17 at 20:29
  • I dont think there is while loop in template, you need to convert your while loop in your component and then iterate that in templage. and I am sure you are not look that. – Aniruddha Das Sep 08 '17 at 20:43
  • Possible duplicate of [Angular 2 - NgFor using numbers instead collections](https://stackoverflow.com/questions/36354325/angular-2-ngfor-using-numbers-instead-collections) – GreyBeardedGeek Sep 09 '17 at 06:01