I’m trying to add 50
to the totalValue if dropdown value is true
.
<div class="col">
<label class="form-label">Emergency</label>
<select class="form-select" name="emergency" id="emergency" [(ngModel)]="registration.emergency" (ngModelChange)="onEmergency()">
<option value="false">No</option>
<option value="true">Yes</option>
</select>
</div>
<div class="col">
<input type="number" class="form-control" name="totalValue" id="totalValue" [(ngModel)]="registration.totalValue" disabled>
</div>
Here’s my .TS file of Angular 17:
onEmergency(){
if(this.registration.emergency === true ){
this.registration.totalValue = Number(this.registration.totalValue) + 50;
}
}
Nothing happens when I select true
in the dropdown. No error either.