Answers for "select option in reactive forms"

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>
Posted by: Guest on March-23-2021
1

select option in reactive forms

// City Names
  City: any = ['Florida', 'South Dakota', 'Tennessee', 'Michigan']
Posted by: Guest on March-23-2021
1

select option in reactive forms

import { Component } from '@angular/core';
import { FormBuilder, Validators } from "@angular/forms";

@Component({
  // ...
})

export class AppComponent {

  constructor(public fb: FormBuilder) { }

  /*########### Form ###########*/
  registrationForm = this.fb.group({
    cityName: ['']
  })

  onSubmit() {
    alert(JSON.stringify(this.registrationForm.value))
  }

}
Posted by: Guest on March-23-2021

Code answers related to "select option in reactive forms"

Code answers related to "Javascript"

Browse Popular Code Answers by Language