Currently, I am using a specialized mat-input-currency format directive to automatically convert my field inputs into currency. You can find the npm repository here.
However, the directive binds the element data to [value]
of the input, and I require it to be 2-way bound to [(ngModel)]
.
The binding functions correctly, but the currency format display is not visible when first loaded; it only appears after clicking on the input and then clicking out. When bound to [value]
, however, it displays in currency format upon loading.
Here is the StackBlitz that I created from the Demo. I attempted to write a function to possibly tap into an onload event for the input, but I am unsure how to proceed. Is there a way to have it load with the ngModel formatted? The event does not appear to trigger on onload.
<mat-form-field *ngIf="mpPatient.ssissdiawardLetter=='Y'" appearance="standard">
<mat-label>SSI/SSDI Award Amount</mat-label>
<input matInput type="text"
(onload)="onLoadCurrencyEvent($event, mpPatient.ssissdiawardAmount)"
mvndrMatCurrencyFormat [allowNegative]="false" [currencyCode]="'USD'"
[(ngModel)]="mpPatient.ssissdiawardAmount"
(blur)="updateUSAmount($event, mpPatient.ssissdiawardAmount)">
</mat-form-field>