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>