Reputation: 2701
This question is from Accessibility perspective. I have a select statement as below and use Angular 2. It works perfectly as it is supposed to while using the mouse. When using the keyboard down arrow key I need to be able to select an option and press enter key so that action takes place. How do I achieve that in select statement.
<select [(ngModel)]="selItem" class="form-control" name="itemSelection" (ngModelChange)="onItemChange($event)"
Also not interested in having a separate submit button to action upon the item that was selected from the select dropdown
Upvotes: 3
Views: 4269
Reputation: 93
Try this:
<select [(ngModel)]="selItem" class="form-control" name="itemSelection" (ngModelChange)="onItemChange($event)">
<option [value]="x" *ngFor="let x of names">{{x}}</option>
</select>
names = ['ram','sham','vijay']
selItem = 'ram';
onItemChange(data) {
console.log(data);
this.selItem = data;
}`enter code here`
Upvotes: 2