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.
use ngModel with ngModelChange
<input materialize="pickadate" [ngModel]="date"
(ngModelChange)="onKey($event)" type="text" class="datepicker" placeholder="Selecione a Data" [materializeParams]=datePickerParams>
I am not an angular expert too, I'm learning. If you use Reactive Form, you can use something like
this.form.get('date').valueChanges.subscribe(date => {
// do what you want
// Tue Apr 03 2018 00:00:00 GMT-0300 (Hora oficial do Brasil)
// you can use date.getTime()
})
You just need to set formControlName in date input! I`d recommend to use reactive form! Can you try and tell me if its worked? Thanks and sorry for my knowlegde and english!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With