reactive forms select option code example
Example 1: select option in reactive forms
<select class="custom-select" (change)="changeCity($event)" formControlName="cityName">
<option value="" disabled>Choose your city</option>
<option *ngFor="let city of City" [ngValue]="city">{{city}}</option>
</select>
Example 2: select option in reactive forms
City: any = ['Florida', 'South Dakota', 'Tennessee', 'Michigan']
Example 3: select option in reactive forms
import { Component } from '@angular/core';
import { FormBuilder, Validators } from "@angular/forms";
@Component({
})
export class AppComponent {
constructor(public fb: FormBuilder) { }
registrationForm = this.fb.group({
cityName: ['']
})
onSubmit() {
alert(JSON.stringify(this.registrationForm.value))
}
}