How to Open p-calendar Programmatically

UI Components for Angular
Post Reply
georgestevens815
Posts: 1
Joined: 31 Oct 2018, 23:44

29 Jan 2019, 01:39

I have tried and failed to open the p-calendar programmatically. Below are a few attempts that did not work for me. Anybody know how to do this?

Code: Select all

<p-calendar #calendar></p-calendar>
<p-button label="Open Calendar" (click)="openCalendar()"></p-button>

Code: Select all

export class AppComponent {

   @ViewChild('calendar') calendar: Calendar
   
   openCalendar() {
      // I tried each of these Individually
      this.calendar.showOverlay()
      this.calendar.inputfieldViewChild.nativeElement.dispatchEvent(new Event('focus'))
      this.calendar.inputfieldViewChild.nativeElement.dispatchEvent(new Event('click'))
   }
}

Post Reply

Return to “PrimeNG”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 22 guests