I'm currently learning Angular 6 and exploring reactive forms. I want to set up a feature where selecting an option in one field will automatically populate another field.
The objective is to have the coefficient input update based on the number selected from the dropdown menu. For instance, choosing '1' should set the coefficient to ".15". Similarly, selecting '2' should correspond to ".175", and '3' to ".2".
What would be the most effective approach to implement this functionality? Thank you for your assistance!
Below is my form setup:
<form name="form" class="form-horizontal" (ngSubmit)="createForm.form.valid && createNewMonitoringPoint()" #createForm="ngForm" novalidate>
<select class="col-md-12 form-control" [(ngModel)]="newmp.number"
[ngClass]="{ 'is-invalid': createForm.submitted && newmp.number.invalid }"
required name="number">
<option value="" disabled selected>Choose...</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
<p>Pipe Roughness Coefficient (n) </p>
<input type="coefficient" id="coefficient"
#coeffcient="ngModel" name="coefficient" [(ngModel)]="newmp.coefficient"
class="form-control" placeholder="e.g. .016" />
<button type="submit" value="Create">Create</button>
</form>