@@ -2,6 +2,8 @@ import {ECalendarValue} from '../common/types/calendar-value-enum';
2
2
import { SingleCalendarValue } from '../common/types/single-calendar-value' ;
3
3
import { ECalendarMode } from '../common/types/calendar-mode-enum' ;
4
4
import {
5
+ ChangeDetectionStrategy ,
6
+ ChangeDetectorRef ,
5
7
Component ,
6
8
EventEmitter ,
7
9
forwardRef ,
@@ -38,6 +40,7 @@ import {DateValidator} from '../common/types/validator.type';
38
40
templateUrl : 'day-calendar.component.html' ,
39
41
styleUrls : [ 'day-calendar.component.less' ] ,
40
42
encapsulation : ViewEncapsulation . None ,
43
+ changeDetection : ChangeDetectionStrategy . OnPush ,
41
44
providers : [
42
45
DayCalendarService ,
43
46
{
@@ -109,8 +112,9 @@ export class DayCalendarComponent implements OnInit, OnChanges, ControlValueAcce
109
112
return this . _currentDateView ;
110
113
}
111
114
112
- constructor ( public dayCalendarService : DayCalendarService ,
113
- public utilsService : UtilsService ) {
115
+ constructor ( public readonly dayCalendarService : DayCalendarService ,
116
+ public readonly utilsService : UtilsService ,
117
+ public readonly cd : ChangeDetectorRef ) {
114
118
}
115
119
116
120
ngOnInit ( ) {
@@ -165,6 +169,8 @@ export class DayCalendarComponent implements OnInit, OnChanges, ControlValueAcce
165
169
166
170
this . weeks = this . dayCalendarService
167
171
. generateMonthArray ( this . componentConfig , this . currentDateView , this . selected ) ;
172
+
173
+ this . cd . markForCheck ( ) ;
168
174
}
169
175
170
176
registerOnChange ( fn : any ) : void {
@@ -252,6 +258,8 @@ export class DayCalendarComponent implements OnInit, OnChanges, ControlValueAcce
252
258
this . currentCalendarMode = mode ;
253
259
this . onNavHeaderBtnClick . emit ( mode ) ;
254
260
}
261
+
262
+ this . cd . markForCheck ( ) ;
255
263
}
256
264
257
265
monthSelected ( month : IMonth ) {
@@ -262,12 +270,15 @@ export class DayCalendarComponent implements OnInit, OnChanges, ControlValueAcce
262
270
263
271
moveCalendarsBy ( current : Moment , amount : number , granularity : moment . unitOfTime . Base = 'month' ) {
264
272
this . currentDateView = current . clone ( ) . add ( amount , granularity ) ;
273
+ this . cd . markForCheck ( ) ;
265
274
}
266
275
267
276
moveCalendarTo ( to : SingleCalendarValue ) {
268
277
if ( to ) {
269
278
this . currentDateView = this . utilsService . convertToMoment ( to , this . componentConfig . format ) ;
270
279
}
280
+
281
+ this . cd . markForCheck ( ) ;
271
282
}
272
283
273
284
shouldShowCurrent ( ) : boolean {
0 commit comments