html
<select class="form-control" id="venue" name="venue1"
formGroupName="venue"
(change)="venue_method($event.target.value)">
<option hidden >Click to choose a venue...</option>
<option [attr.value]="venue.id" *ngFor="let venue of venues">
{{venue.name}}
</option>
<input type="hidden" formControlName="title" name="title">
</select>
Component Code
this.rForm = fb.group({
'venue': fb.group({
'VenueId': [],
'title': [],
'isAvailable': [],
//some more values
}),
//some other controls and groups
});
venue_method(input: any) {
console.log(input)
this.rForm.get('venue').patchValue({ title: input.name });
this.rForm.get('venue').patchValue({ VenueId: input.id });
this.rForm.get('venue').patchValue({isAvailable: true });
//some more patches
console.log(this.rForm.get('venue').value);
}
I want to send the value of all the properties my venue has, eg 'name'& 'id' but with attr value I can only patch one value, whats the proper workaround for this?
Note: I don't want select to enhance into showing all the option, I want to access all the properties of "venue" from "let venue of venues". venue has a venue.name and venue.id , currently i'm able to either access venue.id or venue.name from my "venue_method". how to access both at the same time?