hsuanxyz / ion2-calendar

📅 A date picker components for ionic2 /ionic3 / ionic4
https://hsuanxyz.github.io/demo/ion2-calendar/
MIT License
555 stars 277 forks source link

How can you focus or scrollIntoView of a ion-calander element? #126

Open dmpour23 opened 6 years ago

dmpour23 commented 6 years ago

Hi, I am trying to focus a CalendarComponent on a page. Initially its hidden and when the user clicks a button is shown however I get an error

Cannot read property 'scrollIntoView' of undefined

console.log(this.myCalendar); 
CalendarComponent {calSvc: CalendarService, _view: "days", _calendarMonthValue: Array(2), _showToggleButtons: true, _showMonthPicker: true…}

I am using @ViewChild("calendar") myCalendar:ElementRef;

<ion-calendar #calendar ....> this.renderer.invokeElementMethod(this.myCalendar.nativeElement,'focus');

hsuanxyz commented 6 years ago

Why not use *ngIf

dmpour23 commented 6 years ago

I have used *ngIf / [hidden] the problem is I need it to scroll/focus at the center of the calendar. But can seem to do so any suggestions?