I'm new to angular.
I have an input date picker. I want to get/fetch the date selected in the date picker.
Code: Html file:
<input class="form-control m-input " id="m_datepicker_2_validate" placeholder="Select Date" readonly="" type="text">
I'm trying to console.log the selected date.
In the component.ts file I've added a variable staff_date_booking : Date;
and created a function
bookStaffEmployeeDate(){
console.log("This is the DATE:", this.staff_book_date);
}
and in the html I've added
<input [ngModel]="staff_book_date | date:'yyyy-MM-dd'" class="form-control m-input " id="m_datepicker_2_validate" placeholder="Select Date" readonly="" type="text">
Once the date is selected I'm calling this function on (click) but I'm getting this.staff_book_date as undefined.
How can I store the selected date in a variable like staff_book_date
[ngModel]to[(ngModel)]in your input tag.