1- import { Component , Inject , PLATFORM_ID } from '@angular/core' ;
1+ import { Component , Inject , PLATFORM_ID } from '@angular/core' ;
22import { RouterOutlet } from '@angular/router' ;
3- import { CalendarComponent } from "../../../schedule-x/angular/src/lib/calendar.component" ;
4- import { createCalendar , viewWeek , viewMonthGrid , viewMonthAgenda } from "@schedule-x/calendar" ;
3+ import { CalendarComponent } from '../../../schedule-x/angular/src/lib/calendar.component' ;
4+ import {
5+ createCalendar ,
6+ viewWeek ,
7+ viewMonthGrid ,
8+ viewMonthAgenda ,
9+ CalendarApp ,
10+ } from '@schedule-x/calendar' ;
511import { isPlatformBrowser } from '@angular/common' ;
6- import '@schedule-x/theme-default/dist/calendar.css'
7- import { createEventModalPlugin } from " @schedule-x/event-modal" ;
8- import { createDragAndDropPlugin } from " @schedule-x/drag-and-drop" ;
12+ import '@schedule-x/theme-default/dist/calendar.css' ;
13+ import { createEventModalPlugin } from ' @schedule-x/event-modal' ;
14+ import { createDragAndDropPlugin } from ' @schedule-x/drag-and-drop' ;
915
1016@Component ( {
11- selector : 'app-root' ,
12- imports : [ RouterOutlet , CalendarComponent ] ,
13- templateUrl : './app.component.html' ,
14- styleUrl : './app.component.css'
17+ selector : 'app-root' ,
18+ imports : [ RouterOutlet , CalendarComponent ] ,
19+ templateUrl : './app.component.html' ,
20+ styleUrl : './app.component.css' ,
1521} )
1622export class AppComponent {
1723 title = 'development' ;
18- calendarApp = createCalendar ( {
19- events : [
20- {
21- id : '1' ,
22- title : 'Event 1' ,
23- start : '2024-06-11 08:00' ,
24- end : '2024-06-11 09:00' ,
25- } ,
26- {
27- id : '2' ,
28- title : 'Event 2' ,
29- start : '2024-06-11 10:00' ,
30- end : '2024-06-11 11:00' ,
31- } ,
32- {
33- id : '3' ,
34- title : 'Event 3' ,
35- start : '2024-06-11' ,
36- end : '2024-06-11' ,
37- } ,
38- {
39- id : '4' ,
40- title : 'Event 4' ,
41- start : '2024-06-11' ,
42- end : '2024-06-13' ,
43- }
44- ] ,
45- views : [ viewWeek , viewMonthGrid , viewMonthAgenda ] ,
46- plugins : [
47- createEventModalPlugin ( ) ,
48- createDragAndDropPlugin ( )
49- ]
50- } )
24+ calendarApp : CalendarApp ;
25+ constructor ( @Inject ( PLATFORM_ID ) private platformId : string ) { }
5126
52- constructor (
53- @Inject ( PLATFORM_ID ) private platformId : string ,
54- ) { }
27+ ngOnInit ( ) {
28+ if ( isPlatformBrowser ( this . platformId ) ) {
29+ this . calendarApp = createCalendar ( {
30+ events : [
31+ {
32+ id : '1' ,
33+ title : 'Event 1' ,
34+ start : '2024-06-11 08:00' ,
35+ end : '2024-06-11 09:00' ,
36+ } ,
37+ {
38+ id : '2' ,
39+ title : 'Event 2' ,
40+ start : '2024-06-11 10:00' ,
41+ end : '2024-06-11 11:00' ,
42+ } ,
43+ {
44+ id : '3' ,
45+ title : 'Event 3' ,
46+ start : '2024-06-11' ,
47+ end : '2024-06-11' ,
48+ } ,
49+ {
50+ id : '4' ,
51+ title : 'Event 4' ,
52+ start : '2024-06-11' ,
53+ end : '2024-06-13' ,
54+ } ,
55+ ] ,
56+ views : [ viewWeek , viewMonthGrid , viewMonthAgenda ] ,
57+ plugins : [ createEventModalPlugin ( ) , createDragAndDropPlugin ( ) ] ,
58+ } ) ;
59+ }
60+ }
5561
5662 get isBrowserOnly ( ) : boolean {
5763 return isPlatformBrowser ( this . platformId ) ;
@@ -76,6 +82,6 @@ export class AppComponent {
7682 start : '2024-06-11 10:00' ,
7783 end : '2024-06-11 11:00' ,
7884 } ,
79- ] )
85+ ] ) ;
8086 }
8187}
0 commit comments