Search code examples
angulartypescriptangular5angular2-formsmaterialize

Call method when input text is changed


I'm using Angular 5 with Materialize and I have a datepicker who works perfectly:

<input materialize="pickadate" 
 type="text" class="datepicker" placeholder="Selecione a Data" 
 [materializeParams]=datePickerParams>

I want to call a method like "dateChanged(date)" when this input date is changed, I've tried using (change)="dateChanged($event)" for instance, but isn't working.


Solution

  • use ngModel with ngModelChange

    <input materialize="pickadate"  [ngModel]="date"
     (ngModelChange)="onKey($event)" type="text" class="datepicker" placeholder="Selecione a Data" [materializeParams]=datePickerParams>