@@ -50,10 +50,10 @@ import {ComponentPortal, ComponentType, Portal} from '@angular/cdk/portal';
5050 * Default header of a [MatCalendar].
5151 */
5252@Component ( {
53- selector : 'default -header' ,
53+ selector : 'mat-calendar -header' ,
5454 template : 'default header'
5555} )
56- export class DefaultHeader {
56+ export class MatCalendarHeader {
5757 constructor ( ) {
5858
5959 }
@@ -78,11 +78,15 @@ export class DefaultHeader {
7878} )
7979export class MatCalendar < D > implements AfterContentInit , OnDestroy , OnChanges {
8080
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 > ;
8383
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+ }
8690
8791 private _intlChanges : Subscription ;
8892
@@ -145,7 +149,7 @@ export class MatCalendar<D> implements AfterContentInit, OnDestroy, OnChanges {
145149 ( ! this . dateFilter || this . dateFilter ( date ) ) &&
146150 ( ! this . minDate || this . _dateAdapter . compareDate ( date , this . minDate ) >= 0 ) &&
147151 ( ! this . maxDate || this . _dateAdapter . compareDate ( date , this . maxDate ) <= 0 ) ;
148- }
152+ } ;
149153
150154 /**
151155 * 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 {
221225
222226 ngAfterContentInit ( ) {
223227
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 ) ;
233229
234230 this . _activeDate = this . startAt || this . _dateAdapter . today ( ) ;
235231 this . _focusActiveCell ( ) ;
0 commit comments