I'm trying to have a button clear a text input element in Angular 6.
<input #gf type="text" (input)="dt.filterGlobal($event.target.value, 'contains')">
<button (click)="gf.value = '';"></button>
In the markup above I have an input of type text that calls a filterGlobal method when data is entered into the input. Below that is a button that clears the value of the input when clicked. When clicke, the text disappears from the input but the input element's input event doesn't get triggered and therefore the filterGlobal method doesn't get called. Is there something wrong there? I would think changing the model's value would cause an input event to be triggered.
But if nothing is wrong, how can I fire the trigger from the button's click event? I could do this if I absolutely had to:
<button (click)="gf.value = ''; dt.filterGlobal($event.target.value, 'contains')"></button>
But now I'm duplicating code and if someone changes that input event handler without updating the click event handler...