I'm facing an issue with a p-calendar in a priming theme using Angular 2. I am trying to clear the calendar value once a user selects a date and set it to a blank value. Here's my code:
Component
<div style="margin-right: -6px">
<p-calendar [(ngModel)]="viewModel.fromDate" [showIcon]="true" readOnlyInputText="true" (click)="restoreValues()"></p-calendar>
</div>
TypeScript file
export class RequestSearcherComponent implements OnInit {
restoreValues(): void {
this.viewModel.areaIds = [];
this.viewModel.cedingIds = [];
this.viewModel.requestType = [];
this.viewModel.requestResponsible = [];
this.viewModel.requestStatus = [];
this.fromDate.setDate(null);
}
}
I've tried various methods and approaches like the setDate
method mentioned in the code. But unfortunately, none of them seem to work :(
Any help would be greatly appreciated!
Thank you in advance.