@@ -13,6 +13,10 @@ import { deepEqual } from './fast-deep-equal';
1313import { deepCopy , shallowCopy , mapHash } from './utils' ;
1414import { OPTION_IS_DEEP } from './options' ;
1515
16+ type CalendarOptionsLookup < OptionName > = OptionName extends keyof CalendarOptions
17+ ? CalendarOptions [ OptionName ]
18+ : unknown
19+
1620@Component ( {
1721 selector : 'full-calendar' ,
1822 template : '' ,
@@ -21,6 +25,9 @@ import { OPTION_IS_DEEP } from './options';
2125export class FullCalendarComponent implements AfterViewInit , DoCheck , AfterContentChecked , OnDestroy {
2226
2327 @Input ( ) options ?: CalendarOptions ;
28+ @Input ( ) events ?: CalendarOptionsLookup < 'events' > ;
29+ @Input ( ) eventSources ?: CalendarOptionsLookup < 'eventSources' > ;
30+ @Input ( ) resources ?: CalendarOptionsLookup < 'resources' > ;
2431 @Input ( ) deepChangeDetection ?: boolean ;
2532
2633 private calendar : Calendar | null = null ;
@@ -31,7 +38,7 @@ export class FullCalendarComponent implements AfterViewInit, DoCheck, AfterConte
3138
3239 ngAfterViewInit ( ) {
3340 const { deepChangeDetection } = this ;
34- const options = this . options || { } ;
41+ const options = this . buildOptions ( ) ;
3542
3643 // initialize snapshot
3744 this . optionSnapshot = mapHash ( options , ( optionVal : any , optionName : string ) => (
@@ -51,7 +58,7 @@ export class FullCalendarComponent implements AfterViewInit, DoCheck, AfterConte
5158 ngDoCheck ( ) {
5259 if ( this . calendar ) { // not the initial render
5360 const { deepChangeDetection, optionSnapshot } = this ;
54- const newOptions = this . options || { } ;
61+ const newOptions = this . buildOptions ( ) ;
5562 const newProcessedOptions : Record < string , any > = { } ;
5663 let anyChanges = false ;
5764
@@ -116,4 +123,20 @@ export class FullCalendarComponent implements AfterViewInit, DoCheck, AfterConte
116123 return this . calendar ! ;
117124 }
118125
126+ private buildOptions ( ) : CalendarOptions {
127+ const options = { ...this . options } ;
128+
129+ if ( this . events !== undefined ) {
130+ ( options as any ) . events = this . events ;
131+ }
132+ if ( this . eventSources !== undefined ) {
133+ ( options as any ) . eventSources = this . eventSources ;
134+ }
135+ if ( this . resources !== undefined ) {
136+ ( options as any ) . resources = this . resources ;
137+ }
138+
139+ return options ;
140+ }
141+
119142}
0 commit comments