Sunday, February 18, 2018

set the value of a reactive forms control in Angular 4

This won't work:

private updateFillInTheBlankSister(fillInTheBlankSister:FormControl, event:any){
   fillInTheBlankSister.value = event.target.
         options[event.target.options.selectedIndex].value;
}

 
 

This will work however:

private updateFillInTheBlankSister(fillInTheBlankSister:FormControl, event:any){
   fillInTheBlankSister.setValue(event.target.
         options[event.target.options.selectedIndex].value);
}

No comments:

Post a Comment