Yet very basic thing, but I am unable to figure out how to display array of strings in html template in angular2.
.html
<ul>
<li *ngFor="#number of numberOptions">
{{number}}
</li>
</ul>
.ts
this.numberOptions= ["I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX", "X"];
The above trick is not working for me, text editor shows error for #number
in ngFor
. Is this deprecated in new versions? or am I doing anything wrong here?
You have to declare the variable number
with let
.
<li *ngFor="let number of numberOptions">
{{number}}
</li>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With