Angular Typescript input change Event

Asked

Viewed 582 times

0

I have an input field that starts with a number('.2-2'). This input is updated when a select field modifies its value. When this field is modified, the value of the numver input does not obey the formatting. Default value comes by formatted default

<div class="col-sm-12 col">

  <label class="control-label" for="ID_MONTHLY_VALUE">{{txtMonthl_value}}</label>
  <input type="text" style="text-align:right;font-weight: bold" formControlName="OriginalMonthlyValue" class="form-control input-sm" disabled />
  <!--<input type="text" style="text-align:right;font-weight: bold" [(ngModel)]="OriginalMonthlyValue.value" class="form-control input-sm" />-->

</div>

I am looking for a solution. Someone has already been through this problem and can kindly help me ?

1 answer

0

You will have to point directly at the formControl inside the formGroup (Pex formGroup.OriginalMonthlyValue) and then do setValue() in that form-control.

Since you are not using ngModel, the template associated with formControl (aka its value prop) has never been updated automatically, so you will have to do it by hand. if!! (however) the input is changed by the user - this setValue is done automatically.

More information about Formcontrol

Browser other questions tagged

You are not signed in. Login or sign up in order to post.