Is there a better way to implement a drop down in Angular2
I am doing the following
In the template
<select (change)="onSelect($event.target.value)">
<option *ngFor="#taskstatus of dropdownValues" [value]="taskstatus.value">{{taskstatus.name}}</option>
</select>
In the component class
export class CreateTaskComponent {
public selectedStatus: Taskstatus = this.dropdownValues[0];
public dropdownValues: Taskstatus[] = [
{"name":"OPEN","value":"OPEN"},
{"name":"CLOSED","value":"CLOSED"}
];
onSelect(taskevent) {
this.selectedStatus = null;
for (var i = 0; i < this.dropdownValues.length; i++)
{
if (this.dropdownValues[i].value == taskevent) {
this.selectedStatus = this.dropdownValues[i];
console.log(this.selectedStatus.value);
}
}
}
}
class Taskstatus{
name: string;
value: string;
}
Is there a simpler approach to this ?