I have a form where I use select options. This component is to add Jobs and you can select a Client which contains a Client Name, Address, Telephone and Fax (you add those from the Client page) OR you can manually add it on the specific job.
When there are Clients in the list you can select the client and it will automaticly fill the client phone, fax and address but I don't know how to pass my entire client from the NgFor back to the controller. What I tried so far is to put the option in an NgModel and on the select Change find the correct client in the array that is equal to that ngModel value but Im sure there is a better way to do that ?
<select *ngIf="!manualClient" name="clientName" (change)="fillClientValues()" id="clientNameSelect" formControlName="clientName" class="form-control">
<option *ngFor="let client of allClients" [(ngModel)]="selectedClient" value="{{client.name}}">{{client.name}}</option>
</select>
If I could pass the client from ngFor it would be much easier.
selectedClient? Should not the ngModel be bound to client like [(ngModel)]="client" - dileepkumar jami