Mel Pacheco
Mel Pacheco

Reputation: 789

ng2-datepicker run function on date change

I'm using ng2-datepicker the html looks like this.

    <datepicker [(ngModel)]="selectedDate"></datepicker>

I'm not sure how to run a function when the date is changed when using two-way data binding.

Upvotes: 1

Views: 1318

Answers (1)

Armen Vardanyan
Armen Vardanyan

Reputation: 3315

Just use

<datepicker [(ngModel)]="selectedDate" (ngModelChange)="myHandler($event)"></datepicker>

ngModelChange will call the handler, and the value of $event will be the new value of the ngModel.

Upvotes: 2

Related Questions