Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

set selected value of dropdown using formcontrol in angular

this.countryForm.controls['country'].valueChanges.subscribe(country => 
  this.person.country = country;
);

// initialize by finding the correct country object (this will overwrite the person's country object)
this.countryForm.controls['country'].setValue(countries.filter(c => c.id === person.country.id));
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #set #selected #dropdown #formcontrol #angular
ADD COMMENT
Topic
Name
3+3 =