I want to remove the letters and leave only numbers, the validation is fine but the input view does not update correctly.
the variable "quantity" does change its value and I can show it below with
<p> {{quantity}} </p>
button-add.component.html
<input
[ngModel]="quantity"
(ngModelChange)="quantity = changeQuantity($event)"
/>
<p> {{quantity}} </p>
button-add.component.ts
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
@Component({
selector: 'button-add-button',
templateUrl: './button-add.component.html',
styleUrls: ['./button-add.component.scss'],
})
export class ButtonAddComponent implements OnInit {
quantity: number = 10;
constructor() {}
public changeQuantity(cant: string) {
return parseInt(cant.replace(/[^0-9]+/g, ''));
}
}