Issue
I am working with Angular 2 and I am having problems to get the number of options of a select.
I am able to get the total number of options that have a select:
<select class="form-control"(change)="carSelected(index = $event.target.selectedIndex);"
required>
<option></option>
<option *ngFor="let oneCar of car.fourDoors">{{oneCar.name}}</option>
<option *ngFor="let oneCar of car.twoDoors">{{oneCar.name}}</option>
</select>
using index = $event.target.selectedIndex and it perfectly works.
What i need
but what i need is to check how many options of car.fourDoors are. Any idea?
Solution
To get the length of any array call its member length
car.fourDoors.length
Answered By - Iancovici
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.