@@ -10,7 +10,8 @@ import {
10
10
ElementRef ,
11
11
AfterViewInit ,
12
12
ViewChildren ,
13
- QueryList
13
+ QueryList ,
14
+ AfterViewChecked
14
15
} from '@angular/core' ;
15
16
import { NG_VALUE_ACCESSOR } from '@angular/forms' ;
16
17
import { fadeIn , scaleInCenter } from '../animations/main' ;
@@ -69,7 +70,7 @@ export interface IMonthView {
69
70
selector : 'igx-calendar' ,
70
71
templateUrl : 'calendar.component.html'
71
72
} )
72
- export class IgxCalendarComponent extends IgxMonthPickerBase implements AfterViewInit {
73
+ export class IgxCalendarComponent extends IgxMonthPickerBase implements AfterViewInit , AfterViewChecked {
73
74
/**
74
75
* Sets/gets the `id` of the calendar.
75
76
* If not set, the `id` will have value `"igx-calendar-0"`.
@@ -357,11 +358,13 @@ export class IgxCalendarComponent extends IgxMonthPickerBase implements AfterVie
357
358
358
359
public ngAfterViewInit ( ) {
359
360
360
- this . monthViews . forEach ( ( item , index ) => {
361
- const prevMonthView = this . getMonthView ( index - 1 ) ;
362
- const nextMonthView = this . getMonthView ( index + 1 ) ;
363
- item . nextMonthView = nextMonthView ;
364
- item . prevMonthView = prevMonthView ;
361
+ this . monthViews . changes . subscribe ( c => {
362
+ c . forEach ( ( item , index ) => {
363
+ const prevMonthView = this . getMonthView ( index - 1 ) ;
364
+ const nextMonthView = this . getMonthView ( index + 1 ) ;
365
+ item . nextMonthView = nextMonthView ;
366
+ item . prevMonthView = prevMonthView ;
367
+ } ) ;
365
368
} ) ;
366
369
367
370
this . startMonthScroll$ . pipe (
@@ -385,6 +388,15 @@ export class IgxCalendarComponent extends IgxMonthPickerBase implements AfterVie
385
388
} ) ;
386
389
}
387
390
391
+ public ngAfterViewChecked ( ) {
392
+ this . monthViews . forEach ( ( item , index ) => {
393
+ const prevMonthView = this . getMonthView ( index - 1 ) ;
394
+ const nextMonthView = this . getMonthView ( index + 1 ) ;
395
+ item . nextMonthView = nextMonthView ;
396
+ item . prevMonthView = prevMonthView ;
397
+ } ) ;
398
+ }
399
+
388
400
/**
389
401
* Returns the locale representation of the month in the month view if enabled,
390
402
* otherwise returns the default `Date.getMonth()` value.
@@ -403,9 +415,9 @@ export class IgxCalendarComponent extends IgxMonthPickerBase implements AfterVie
403
415
*/
404
416
public previousMonth ( isKeydownTrigger = false ) {
405
417
this . viewDate = this . calendarModel . timedelta ( this . viewDate , 'month' , - 1 ) ;
406
- this . dayViews . forEach ( ( val ) => {
407
- val . viewDate = this . calendarModel . timedelta ( val . viewDate , 'month' , - 1 ) ;
408
- } ) ;
418
+ // this.dayViews.forEach((val) => {
419
+ // val.viewDate = this.calendarModel.timedelta(val.viewDate, 'month', -1);
420
+ // });
409
421
this . _monthAction = 'prev' ;
410
422
411
423
if ( this . daysView ) {
@@ -418,9 +430,9 @@ export class IgxCalendarComponent extends IgxMonthPickerBase implements AfterVie
418
430
*/
419
431
public nextMonth ( isKeydownTrigger = false ) {
420
432
this . viewDate = this . calendarModel . timedelta ( this . viewDate , 'month' , 1 ) ;
421
- this . dayViews . forEach ( ( val ) => {
422
- val . viewDate = this . calendarModel . timedelta ( val . viewDate , 'month' , 1 ) ;
423
- } ) ;
433
+ // this.dayViews.forEach((val) => {
434
+ // val.viewDate = this.calendarModel.timedelta(val.viewDate, 'month', 1);
435
+ // });
424
436
this . _monthAction = 'next' ;
425
437
426
438
if ( this . daysView ) {
@@ -534,14 +546,23 @@ export class IgxCalendarComponent extends IgxMonthPickerBase implements AfterVie
534
546
this . viewDate = this . calendarModel . timedelta ( date , 'month' , delta ) ;
535
547
}
536
548
549
+ /**
550
+ * @hidden
551
+ */
552
+ public daysViewInit ( event : IgxDaysViewComponent ) {
553
+ // this.monthViews.
554
+ }
555
+
537
556
/**
538
557
* @hidden
539
558
*/
540
559
public changeMonth ( event : Date ) {
541
560
this . viewDate = new Date ( this . viewDate . getFullYear ( ) , event . getMonth ( ) ) ;
542
- this . dayViews . forEach ( ( val , index ) => {
543
- val . viewDate . setMonth ( event . getMonth ( ) + index ) ;
544
- } ) ;
561
+ // this.dayViews.forEach((val, index) => {
562
+ // // val.viewDate.setMonth(event.getMonth() + index);
563
+ // val.viewDate = this.calendarModel.timedelta(val.viewDate, 'month', index);
564
+ // });
565
+
545
566
this . activeView = CalendarView . DEFAULT ;
546
567
547
568
requestAnimationFrame ( ( ) => {
0 commit comments