I am using Angular 2 to build my application. This is my code so far:
Template
<select class="form-control input-xs" [(ngModel)]="filter.coordinatorId" name="coordinatorId" (ngModelChange)="onCoordinatorChange($event)">
<option *ngFor="let coordinator of coordinators; let i = index" [value]="coordinator.id" [selected]="i==0">{{coordinator.name}}</option>
</select>
Component
onCoordinatorChange(coordinatorId: number){
alert(coordinatorId);
//business logic
}
As you can see, I set [value]="coordinator.id" in option so I am getting coordinator.id value in alert, and if I change it to coordinator.name then I will get that value. But here I want to get multiple values like coordinator.id,coordinator.name,coordinator.department etc. So one solution could be using comma separated but that will be ugly and hard to maintain if other parameters come. Do I have any other option to write my function something like:
onCoordinatorChange(coordinatorId: number, name: string, department: string){
alert(coordinatorId);
//business logic
}