Я рекомендую вам использовать ElementRef
. Вы должны определить входные данные ElementRef
в вашем ts
файле:
@ViewChild('customInput', {static: false}) inputEl: ElementRef;
Затем определите его в вашем html
, чтобы код вашего шаблона был изменен на этот
<mat-form-field>
<input #customInput matInput formControlName="PhoneNumber" placeholder="Phone number" mask="(000) 0000-00" prefix="+1" [showMaskTyped]="true">
</mat-form-field>
Теперь вы можете получить доступ к фактическому маскированному значению вашего #customInput
в ts
файле:
showMeInput(): void {
console.log(this.inputEl.nativeElement.value);
}