@@ -50,10 +50,10 @@ import {ComponentPortal, ComponentType, Portal} from '@angular/cdk/portal';
50
50
* Default header of a [MatCalendar].
51
51
*/
52
52
@Component ( {
53
- selector : 'default -header' ,
53
+ selector : 'mat-calendar -header' ,
54
54
template : 'default header'
55
55
} )
56
- export class DefaultHeader {
56
+ export class MatCalendarHeader {
57
57
constructor ( ) {
58
58
59
59
}
@@ -78,11 +78,15 @@ export class DefaultHeader {
78
78
} )
79
79
export class MatCalendar < D > implements AfterContentInit , OnDestroy , OnChanges {
80
80
81
- /** An input indicating the type of the custom header component, if set. */
82
- @Input ( ) customCalendarHeaderComponent : ComponentType < any > ;
81
+ /** An input indicating the type of the header component, if set. */
82
+ @Input ( ) headerComponent : ComponentType < any > ;
83
83
84
- /** A portal containing the header for this calendar. */
85
- calendarHeaderPortal : Portal < any > ;
84
+ /** A portal containing the header component type for this calendar. */
85
+ private _calendarHeaderPortal : Portal < any > ;
86
+
87
+ get calendarHeaderPortal ( ) {
88
+ return this . _calendarHeaderPortal ;
89
+ }
86
90
87
91
private _intlChanges : Subscription ;
88
92
@@ -145,7 +149,7 @@ export class MatCalendar<D> implements AfterContentInit, OnDestroy, OnChanges {
145
149
( ! this . dateFilter || this . dateFilter ( date ) ) &&
146
150
( ! this . minDate || this . _dateAdapter . compareDate ( date , this . minDate ) >= 0 ) &&
147
151
( ! this . maxDate || this . _dateAdapter . compareDate ( date , this . maxDate ) <= 0 ) ;
148
- }
152
+ } ;
149
153
150
154
/**
151
155
* The current active date. This determines which time period is shown and which date is
@@ -221,15 +225,7 @@ export class MatCalendar<D> implements AfterContentInit, OnDestroy, OnChanges {
221
225
222
226
ngAfterContentInit ( ) {
223
227
224
- if ( this . customCalendarHeaderComponent !== undefined ) {
225
- // custom header
226
- this . calendarHeaderPortal = new ComponentPortal ( this . customCalendarHeaderComponent ) ;
227
- } else {
228
- // default header
229
- this . calendarHeaderPortal = new ComponentPortal ( DefaultHeader ) ;
230
- }
231
-
232
- // console.log(this.calendarHeaderPortal)
228
+ this . _calendarHeaderPortal = new ComponentPortal ( this . headerComponent || MatCalendarHeader ) ;
233
229
234
230
this . _activeDate = this . startAt || this . _dateAdapter . today ( ) ;
235
231
this . _focusActiveCell ( ) ;
0 commit comments