@cxfreeze/ionic-calendar 2.4.1 → 2.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/.angular/cache/17.0.1/ng-packagr/content-v2/sha512/1b/1e/cf97a55b067ccc408926c6e68297a355657efa5ce9322e62979a81181e2907907086e271c18bd023f3818781cd1335e027c6b6aa36f2dab4fe0a1bb67fda +1 -0
  2. package/.angular/cache/17.0.1/ng-packagr/content-v2/sha512/1e/f1/a99fe795a5de8a56d13ea52f1e509ffbe943a96d7f901d2c85cd20bffda2e50881362a2d7abf4ce7503a0b548cdfe6985082a626d1b53845eb25685da463 +1 -0
  3. package/.angular/cache/17.0.1/ng-packagr/content-v2/sha512/7e/0b/35625ec42cf042be295cee7a63ffb0bfacd9fff699912626830fb9034cf68e96f82772b8dbab9c5190c75690f8822a25e1094fe16467ac8bf99d5ac88417 +1 -0
  4. package/.angular/cache/17.0.1/ng-packagr/content-v2/sha512/b4/8e/1aba05910d36c5e8b9ede4612b36f257d6ef820d71a959cd371d243f842cb84bc2a83a1c64d76dacef33dd73ea4f71bea67e4a510846bc06b246e53bd9b7 +1 -0
  5. package/.angular/cache/17.0.1/ng-packagr/content-v2/sha512/c2/5f/d2ca0e1d8b734edd9178653a270d326f5282400f3db2953a7bc7b39ff267041b2b176ab7f23d1b7546ee38e236665eaed658a832f2c548abc6dfe6f5d4ae +1 -0
  6. package/.angular/cache/17.0.1/ng-packagr/content-v2/sha512/cb/c6/000b81516d1685a732182dc1834e51acee7de3531482bd05dcaf4d8a769eb3fca034ece03ad5347e67df87ada9909614f6da18c154a3ba3c32017053591a +1 -0
  7. package/.angular/cache/17.0.1/ng-packagr/content-v2/sha512/ed/a6/c97d9a810d6c54af8258867c7b5d6964e237c33352ccad7b977c4c73dcf77c135a00b0d319c5738d7c992ecf95011b45db15967195063bb0d61978bb9513 +1 -0
  8. package/.angular/cache/17.0.1/ng-packagr/index-v5/01/4d/18b7829e2c42b58e4788b3c2abe28abd04de4c6a41e120f159297c938977 +2 -0
  9. package/.angular/cache/17.0.1/ng-packagr/index-v5/0e/32/b7164aca67b994240b6748045ee30505f5bde5fbf7c4499d977965c90db0 +2 -0
  10. package/.angular/cache/17.0.1/ng-packagr/index-v5/22/f0/d38580ba65f27221d0f84e532332ae026d70083cebdfa338a4072993a2ed +2 -0
  11. package/.angular/cache/17.0.1/ng-packagr/index-v5/37/f8/0d0c0072e4754fceba188c3d7885c2facd3c9d6d824040799c56f627b095 +2 -0
  12. package/.angular/cache/17.0.1/ng-packagr/index-v5/9d/7c/eb0891e7f07eed83db9fc9d2b595b57f8f0f8dd140cd815fc71a0911ab33 +2 -0
  13. package/.angular/cache/17.0.1/ng-packagr/index-v5/b4/fc/414f1e68224aaaf8ec4ab411568070ffffe2096b5c81ddba81c4bbf786bd +2 -0
  14. package/.angular/cache/17.0.1/ng-packagr/index-v5/e3/73/1f46c305202b8d9c3dc352bae8fca38e2b222b28513fa03a8122bb362cd0 +2 -0
  15. package/.angular/cache/17.0.1/ng-packagr/tsbuildinfo/cxfreeze-ionic-calendar.tsbuildinfo +1 -0
  16. package/dist/LICENSE +21 -0
  17. package/dist/README.md +1014 -0
  18. package/dist/calendar.d.ts +84 -0
  19. package/dist/calendar.interface.d.ts +163 -0
  20. package/dist/calendar.module.d.ts +13 -0
  21. package/dist/calendar.service.d.ts +30 -0
  22. package/dist/dayview.d.ts +87 -0
  23. package/dist/esm2022/calendar.interface.mjs +7 -0
  24. package/dist/esm2022/calendar.mjs +249 -0
  25. package/dist/esm2022/calendar.module.mjs +25 -0
  26. package/dist/esm2022/calendar.service.mjs +140 -0
  27. package/dist/esm2022/cxfreeze-ionic-calendar.mjs +5 -0
  28. package/dist/esm2022/dayview.mjs +594 -0
  29. package/dist/esm2022/index.mjs +4 -0
  30. package/dist/esm2022/init-position-scroll.mjs +63 -0
  31. package/dist/esm2022/monthview.mjs +462 -0
  32. package/dist/esm2022/weekview.mjs +705 -0
  33. package/dist/fesm2022/cxfreeze-ionic-calendar.mjs +2214 -0
  34. package/dist/fesm2022/cxfreeze-ionic-calendar.mjs.map +1 -0
  35. package/dist/index.d.ts +3 -0
  36. package/dist/init-position-scroll.d.ts +18 -0
  37. package/dist/monthview.d.ts +72 -0
  38. package/dist/weekview.d.ts +91 -0
  39. package/package.json +1 -1
package/dist/README.md ADDED
@@ -0,0 +1,1014 @@
1
+ # Ionic-Calendar directive
2
+
3
+ Ionic calendar directive
4
+
5
+ [![version](https://img.shields.io/npm/v/ionic2-calendar/latest.svg)](https://www.npmjs.com/package/ionic2-calendar)
6
+ [![GitHub License](https://img.shields.io/npm/l/ionic2-calendar.svg)](https://raw.githubusercontent.com/twinssbc/Ionic2-Calendar/master/LICENSE)
7
+
8
+ # Table of Contents
9
+ 1. [Demo](#demo)
10
+ 2. [Dependency](#dependency)
11
+ 3. [Usage](#usage)
12
+ 4. [Options](#options)
13
+ 5. [Callback](#callback)
14
+ 6. [View Customization Option](#view-customization-option)
15
+ 7. [EventSource](#eventsource)
16
+ 8. [Performance Tuning](#performance-tuning)
17
+ 9. [Common Questions](#common-questions)
18
+
19
+ # Demo
20
+ Version 2.0
21
+ https://stackblitz.com/edit/ionic-calendar-demo-2-2?file=src%2Fapp%2Fexample.component.html
22
+ Version 1.0
23
+ https://stackblitz.com/edit/ionic-calendar-demo-1-0?file=src%2Fapp%2Fexample.component.html
24
+ Version 0.x
25
+ https://stackblitz.com/edit/ionic-calendar-demo?file=pages%2Fhome%2Fhome.html
26
+
27
+ ## Month View
28
+ ![Month View](https://github.com/twinssbc/ionic-calendar-demo/blob/main/images/month-view.png)
29
+
30
+ ## Week View
31
+ ![Week View](https://github.com/twinssbc/ionic-calendar-demo/blob/main/images/week-view.png)
32
+
33
+ ## Day View
34
+ ![Day View](https://github.com/twinssbc/ionic-calendar-demo/blob/main/images/day-view.png)
35
+
36
+ ## Day View - Categorized
37
+ ![Day View Categorized](https://github.com/twinssbc/ionic-calendar-demo/blob/main/images/day-view-categorized.png)
38
+
39
+ # Dependency
40
+ Version 2.3.x depends on Ionic (>=7.0.0), Angular (>=17.0.0) and Swiper (>=11.0.0).
41
+ Version 2.2.x depends on Ionic (>=7.0.0), Angular (>=17.0.0) and Swiper (>=10.1.0).
42
+ Version 2.1.x depends on Ionic (>=7.0.0), Angular (>=16.0.0) and Swiper (>=10.1.0).
43
+ Version 2.0.x depends on Ionic (>=7.0.0), Angular (>=16.0.0) and Swiper (>=8.4.6, <9.0.0).
44
+ Version 1.0.x depends on Ionic (>=6.1.9), Angular (>=15.1.2) and Swiper (>=8.4.6, <9.0.0).
45
+ Version 0.6.x depends on Ionic (>=5.1.0) and Angular (>=9.1.0).
46
+ version 0.5.x depends on Ionic (>=4.0.0-rc.1), also supports Ionic 5.0.0.
47
+ version 0.4.x depends on Ionic (>=3.9.2).
48
+ version 0.3.x depends on Ionic (>=3.1.1).
49
+ version 0.2.9+ depends on Ionic (>=2.3.0).
50
+ version 0.2.x depends on Ionic 2.0.0-rc.5 (rc.5 has breaking change on the slide API) and 2.0.0 final version onwards.
51
+ version 0.1.x depends on Ionic 2.0.0-rc.1 ~ Ionic 2.0.0-rc.4
52
+
53
+ version 0.2-0.4 has below dependency:
54
+ intl 1.2.5, due to issue https://github.com/angular/angular/issues/3333
55
+
56
+ # Usage
57
+
58
+ ## 1. Install Calendar Dependency
59
+ `npm install ionic2-calendar --save`
60
+
61
+ ### version 1.0.x onwards
62
+ version 1.0.x is also published as Ionic6-Calendar package name. So could also run
63
+ `npm install ionic6-calendar --save`
64
+ version 2.0.x is also published as Ionic7-Calendar package name. So could also run
65
+ `npm install ionic7-calendar --save`
66
+
67
+ <font color=red>**NOTE: Starting from Version 1.0.x, the underlying implementaion is based on Swiper instead of IonSlides, so also needs to install Swiper dependency.**</font>
68
+ - Install swiper dependency
69
+ `npm install swiper --save`
70
+
71
+ - Import swiper css in **global.scss**
72
+ ```
73
+ @import 'swiper/css';
74
+ ```
75
+
76
+ ## 2. Import the Calendar module
77
+ If using version 1.0.x, could use both ionic2-calendar or ionic6-calendar, ionic7-calendar.
78
+
79
+ - version 0.5.x onwards
80
+ ``` typescript
81
+ import { NgModule } from '@angular/core';
82
+ import { IonicApp, IonicModule } from '@ionic/angular';
83
+ import { MyApp } from './app/app.component';
84
+ import { NgCalendarModule } from 'ionic2-calendar';
85
+
86
+ @NgModule({
87
+ declarations: [
88
+ MyApp
89
+ ],
90
+ imports: [
91
+ NgCalendarModule,
92
+ IonicModule.forRoot(MyApp)
93
+ ],
94
+ bootstrap: [IonicApp],
95
+ entryComponents: [
96
+ MyApp
97
+ ]
98
+ })
99
+ export class AppModule {}
100
+ ```
101
+
102
+ - version 0.1.x - 0.4.x
103
+ ``` typescript
104
+ import { NgModule } from '@angular/core';
105
+ import { IonicApp, IonicModule } from 'ionic-angular';
106
+ import { MyApp } from './app/app.component';
107
+ import { NgCalendarModule } from 'ionic2-calendar';
108
+
109
+ @NgModule({
110
+ declarations: [
111
+ MyApp
112
+ ],
113
+ imports: [
114
+ NgCalendarModule,
115
+ IonicModule.forRoot(MyApp)
116
+ ],
117
+ bootstrap: [IonicApp],
118
+ entryComponents: [
119
+ MyApp
120
+ ]
121
+ })
122
+ export class AppModule {}
123
+ ```
124
+
125
+ If you are using PageModule, you need to import the NgCalendarModule in your page module
126
+
127
+ ``` typescript
128
+ import { NgCalendarModule } from 'ionic2-calendar';
129
+
130
+ @NgModule({
131
+ declarations: [
132
+ MyPage
133
+ ],
134
+ imports: [
135
+ IonicPageModule.forChild(MyPage),
136
+ NgCalendarModule
137
+ ],
138
+ entryComponents: [
139
+ MyPage
140
+ ]
141
+ })
142
+ export class MyPageModule {}
143
+ ```
144
+
145
+ ## 3. Add the directive in the html page
146
+
147
+ ``` html
148
+ <calendar [eventSource]="eventSource"
149
+ [calendarMode]="calendar.mode"
150
+ [currentDate]="calendar.currentDate"
151
+ (onCurrentDateChanged)="onCurrentDateChanged($event)"
152
+ (onRangeChanged)="reloadSource(startTime, endTime)"
153
+ (onEventSelected)="onEventSelected($event)"
154
+ (onTitleChanged)="onViewTitleChanged($event)"
155
+ (onTimeSelected)="onTimeSelected($event)"
156
+ [step]="calendar.step">
157
+ </calendar>
158
+ ```
159
+
160
+
161
+ # Options
162
+
163
+ * formatDay
164
+ The format of the date displayed in the month view.
165
+ Default value: 'dd'
166
+ * formatDayHeader
167
+ The format of the header displayed in the month view.
168
+ Default value: 'EEE'
169
+ * formatDayTitle
170
+ The format of the title displayed in the day view.
171
+ Default value: 'MMMM dd, yyyy'
172
+ * formatWeekTitle
173
+ The format of the title displayed in the week view.
174
+ Default value: (version 0.1-0.3) 'MMMM yyyy, Week $n', (version 0.4+) 'MMMM yyyy, \'Week\' w'
175
+ * formatMonthTitle
176
+ The format of the title displayed in the month view.
177
+ Default value: 'MMMM yyyy'
178
+ * formatWeekViewDayHeader
179
+ The format of the header displayed in the week view.
180
+ Default value: 'EEE d'
181
+ * formatHourColumn
182
+ The format of the hour column displayed in the week and day view.
183
+ Default value: (version 0.1-0.3) 'j', (version 0.4+) 'ha'
184
+ * calendarMode
185
+ The initial mode of the calendar.
186
+ Default value: 'month'
187
+
188
+ ``` html
189
+ <calendar ... [calendarMode]="calendar.mode"></calendar>
190
+ ```
191
+
192
+ Version 1.0.x onwards
193
+ ```typescript
194
+ import { CalendarMode } from 'ionic2-calendar';
195
+
196
+ calendar = {
197
+ mode: 'week' as CalendarMode
198
+ };
199
+ ```
200
+
201
+ Version 0.x
202
+ ```typescript
203
+ import { CalendarMode } from 'ionic2-calendar/calendar';
204
+
205
+ calendar = {
206
+ mode: 'week' as CalendarMode
207
+ };
208
+ ```
209
+
210
+ * showEventDetail
211
+ If set to true, when selecting the date in the month view, the events happened on that day will be shown below.
212
+ Default value: true
213
+ * startingDayMonth
214
+ Control month view starting from which day.
215
+ Default value: 0 (Sunday)
216
+ * startingDayWeek
217
+ Control week view starting from which day.
218
+ Default value: 0 (Sunday)
219
+ * allDayLabel
220
+ The text displayed in the allDay column header of week and day view.
221
+ Default value: 'all day'
222
+ * noEventsLabel
223
+ The text displayed when there’s no event on the selected date in month view.
224
+ Default value: 'No Events'
225
+ * eventSource
226
+ The data source of the calendar, when the eventSource is set, the view will be updated accordingly.
227
+ Default value: null
228
+ The format of the eventSource is described in the [EventSource](#eventsource) section
229
+ * queryMode
230
+ If queryMode is set to 'local', when the range or mode is changed, the calendar will use the already bound eventSource to update the view
231
+ If queryMode is set to 'remote', when the range or mode is changed, the calendar will trigger a callback function rangeChanged.
232
+ Users will need to implement their custom loading data logic in this function, and fill it into the eventSource. The eventSource is watched, so the view will be updated once the eventSource is changed.
233
+ Default value: 'local'
234
+ * step
235
+ It is used to display the event using more accurate time interval in weekview and dayview. For example, if set to 30, then the event will only occupy half of the row height (If timeInterval option uses default value). The unit is minute. It can be set to 15 or 30.
236
+ Default value: 60
237
+ ``` html
238
+ <calendar ... [step]="calendar.step"></calendar>
239
+ ```
240
+
241
+ ```typescript
242
+ import { Step } from 'ionic2-calendar/calendar';
243
+
244
+ calendar = {
245
+ step: 30 as Step
246
+ };
247
+ ```
248
+
249
+ * timeInterval (version >= 0.3)
250
+ It is used to display the rows using more accurate time interval in weekview and dayview. For example, if set to 30, then the time interval between each row is 30 mins.
251
+ The unit is minute. It should be the factor or multiple of 60, which means 60%timeInterval=0 or timeInterval%60=0.
252
+ Default value: 60
253
+ ``` html
254
+ <calendar ... [timeInterval]="30"></calendar>
255
+ ```
256
+
257
+ * autoSelect
258
+ If set to true, the current calendar date will be auto selected when calendar is loaded or swiped in the month and week view.
259
+ Default value: true
260
+ * locale
261
+ The locale used to display text in the calendar.
262
+ Check [Localization](#localization) section for more details.
263
+ Default value: undefined (which means the local language)
264
+ ``` html
265
+ <calendar ... [locale]="calendar.locale"></calendar>
266
+ ```
267
+ ``` typescript
268
+ calendar = {
269
+ locale: 'en-GB'
270
+ };
271
+ ```
272
+ * markDisabled
273
+ The callback function used to determine if the time should be marked as disabled.
274
+ ``` html
275
+ <calendar ... [markDisabled]="markDisabled"></calendar>
276
+ ```
277
+ ``` typescript
278
+ markDisabled = (date: Date) => {
279
+ var current = new Date();
280
+ return date < current;
281
+ };
282
+ ```
283
+ * dateFormatter
284
+ The custom date formatter to transform date to text.
285
+ If the custom date formatter is not set, the default Angular DatePipe is used.
286
+ The format method in dateFormatter is optional, if omitted, the default Angular DatePipe is used.
287
+ ``` html
288
+ <calendar ... [dateFormatter]="calendar.dateFormatter"></calendar>
289
+ ```
290
+ ``` typescript
291
+ calendar = {
292
+ dateFormatter: {
293
+ formatMonthViewDay: function(date:Date) {
294
+ return date.getDate().toString();
295
+ },
296
+ formatMonthViewDayHeader: function(date:Date) {
297
+ return 'testMDH';
298
+ },
299
+ formatMonthViewTitle: function(date:Date) {
300
+ return 'testMT';
301
+ },
302
+ formatWeekViewDayHeader: function(date:Date) {
303
+ return 'testWDH';
304
+ },
305
+ formatWeekViewTitle: function(date:Date) {
306
+ return 'testWT';
307
+ },
308
+ formatWeekViewHourColumn: function(date:Date) {
309
+ return 'testWH';
310
+ },
311
+ formatDayViewHourColumn: function(date:Date) {
312
+ return 'testDH';
313
+ },
314
+ formatDayViewTitle: function(date:Date) {
315
+ return 'testDT';
316
+ }
317
+ }
318
+ };
319
+ ```
320
+ * dir
321
+ If set to "rtl", the calendar supports RTL language. This feature is only supported in Ionic 2.3.0 version onwards.
322
+ Default value: ""
323
+
324
+ * scrollToHour
325
+ Make weekview and dayview scroll to the specific hour after entering to the new view.
326
+ Default value: 0
327
+
328
+ * preserveScrollPosition
329
+ If set to true, the previous/next views in weekview and dayview will also scroll to the same position as the current active view.
330
+ Default value: false
331
+
332
+ * lockSwipeToPrev
333
+ If set to true, swiping to previous view is disabled.
334
+ Default value: false
335
+ ``` html
336
+ <calendar ... [lockSwipeToPrev]="lockSwipeToPrev"></calendar>
337
+ ```
338
+ ``` typescript
339
+ onCurrentDateChanged(event:Date) {
340
+ var today = new Date();
341
+ today.setHours(0, 0, 0, 0);
342
+ event.setHours(0, 0, 0, 0);
343
+
344
+ if (this.calendar.mode === 'month') {
345
+ if (event.getFullYear() < today.getFullYear() || (event.getFullYear() === today.getFullYear() && event.getMonth() <= today.getMonth())) {
346
+ this.lockSwipeToPrev = true;
347
+ } else {
348
+ this.lockSwipeToPrev = false;
349
+ }
350
+ }
351
+ }
352
+ ```
353
+
354
+ * lockSwipeToNext (version 1.0.x onwards)
355
+ If set to true, swiping to next view is disabled.
356
+ Default value: false
357
+ ``` html
358
+ <calendar ... [lockSwipeToNext]="lockSwipeToNext"></calendar>
359
+ ```
360
+ ``` typescript
361
+ onCurrentDateChanged(event:Date) {
362
+ var today = new Date();
363
+ today.setHours(0, 0, 0, 0);
364
+ event.setHours(0, 0, 0, 0);
365
+
366
+ if (this.calendar.mode === 'month') {
367
+ if (event.getFullYear() > today.getFullYear() || (event.getFullYear() === today.getFullYear() && event.getMonth() >= today.getMonth())) {
368
+ this.lockSwipeToNext = true;
369
+ } else {
370
+ this.lockSwipeToNext = false;
371
+ }
372
+ }
373
+ }
374
+ ```
375
+
376
+
377
+ * lockSwipes
378
+ If set to true, swiping is disabled.
379
+ Default value: false
380
+
381
+ **Version 1.x**
382
+ *Note:* Since swiping is disabled, you could set currentDate or call slideToPrev/slideToNext [method](#instance-methods) to move the calendar to previous/next view. You need to first set the lockSwipes to false, move the slide, then set it back.
383
+ ``` html
384
+ <calendar ... [lockSwipes]="lockSwipes"></calendar>
385
+ ```
386
+ ``` typescript
387
+ moveSlide() {
388
+ this.calendar.lockSwipes = false;
389
+ setTimeout(function() {
390
+ this.myCalendar.slideNext();
391
+ this.calendar.lockSwipes = true;
392
+ },100);
393
+ }
394
+ ```
395
+
396
+ **Version 0.x**
397
+ *Note:* Since swiping is disabled, you could set currentDate or call slideToPrev/slideToNext [method](#instance-methods) to move the calendar to previous/next view. Do not set lockSwipeToPrev in the constructor phase. It will cause the view not updating when changing the currentDate. You could either set it in some callback function after initialization phase or use setTimeout to trigger some delay.
398
+ ``` html
399
+ <calendar ... [lockSwipes]="lockSwipes"></calendar>
400
+ ```
401
+ ``` typescript
402
+ ngAfterViewInit() {
403
+ var me = this;
404
+ setTimeout(function() {
405
+ me.lockSwipes = true;
406
+ },100);
407
+ }
408
+ ```
409
+
410
+ * startHour
411
+ Limit the weekview and dayview starts from which hour (0-23).
412
+ Default value: 0
413
+ ``` html
414
+ <calendar ... startHour="9"></calendar>
415
+ ```
416
+
417
+ * endHour
418
+ Limit the weekview and dayview ends until which hour (1-24).
419
+ Default value: 24
420
+ ``` html
421
+ <calendar ... endHour="19"></calendar>
422
+ ```
423
+
424
+ * sliderOptions
425
+ Options to pass to the underlying swiper instance. See https://swiperjs.com/swiper-api#parameters for valid options.
426
+ ``` html
427
+ <calendar ... sliderOptions="sliderOptions"></calendar>
428
+ ```
429
+ ``` typescript
430
+ options = {
431
+ spaceBetween: 10,
432
+ threshold: 50
433
+ };
434
+ ```
435
+
436
+ * `dayviewShowCategoryView` (version: 2.4+)
437
+ Determines if show dayview with category
438
+ Type: `boolean`
439
+ Default value: `false`
440
+
441
+
442
+ * `dayviewCategorySource` (version: 2.4+)
443
+ Determines the source the category names so that events with corresponding category will display accordingly. If events are not assigned with category, they will NOT be placed in the category view.
444
+ Type: `Set<string>`
445
+ Default value: `null`
446
+ ``` html
447
+ <calendar ... [dayviewCategorySource]="calendar.dayviewCategorySource"></calendar>
448
+ ```
449
+ ``` typescript
450
+ calendar = {
451
+ dayviewCategorySource: new Set<string>(['Alice', 'Bob', 'Charlie'])
452
+ };
453
+ ```
454
+
455
+ # Callback
456
+ * onCurrentDateChanged
457
+ The callback function triggered when the date that is currently viewed changes.
458
+ ``` html
459
+ <calendar ... (onCurrentDateChanged)="onCurrentDateChanged($event)"></calendar>
460
+ ```
461
+ ``` typescript
462
+ onCurrentChanged = (ev: Date) => {
463
+ console.log('Currently viewed date: ' + ev);
464
+ };
465
+ ```
466
+ * onRangeChanged
467
+ The callback function triggered when the range or mode is changed if the **queryMode** is set to '**remote**'
468
+ The ev parameter contains two fields, startTime and endTime.
469
+ ``` html
470
+ <calendar ... (onRangeChanged)="onRangeChanged($event)"></calendar>
471
+ ```
472
+ ``` typescript
473
+ onRangeChanged = (ev: { startTime: Date, endTime: Date }) => {
474
+ Events.query(ev, (events) => {
475
+ this.eventSource = events;
476
+ });
477
+ };
478
+ ```
479
+ * onEventSelected
480
+ The callback function triggered when an event is clicked
481
+ ``` html
482
+ <calendar ... (onEventSelected)="onEventSelected($event)"></calendar>
483
+ ```
484
+ ``` typescript
485
+ onEventSelected = (event) => {
486
+ console.log(event.title);
487
+ };
488
+ ```
489
+ * onTimeSelected
490
+ The callback function triggered when a time slot is selected.
491
+ The ev parameter contains three fields, selectedTime, events and disabled, if there's no event at the selected time, the events field will be either undefined or empty array
492
+ ``` html
493
+ <calendar ... (onTimeSelected)="onTimeSelected($event)"></calendar>
494
+ ```
495
+ ``` typescript
496
+ onTimeSelected = (ev: { selectedTime: Date, events: any[], disabled: boolean }) => {
497
+ console.log('Selected time: ' + ev.selectedTime + ', hasEvents: ' + (ev.events !== undefined && ev.events.length !== 0) + ', disabled: ' + ev.disabled);
498
+ };
499
+ ```
500
+ * onDayHeaderSelected
501
+ The callback function triggered when a day header is selected in week view.
502
+ The ev parameter contains three fields, selectedTime, events and disabled, if there's no event at the selected time, the events field will be either undefined or empty array
503
+ ``` html
504
+ <calendar ... (onDayHeaderSelected)="onDayHeaderSelected($event)"></calendar>
505
+ ```
506
+ ``` typescript
507
+ onDayHeaderSelected = (ev: { selectedTime: Date, events: any[], disabled: boolean }) => {
508
+ console.log('Selected day: ' + ev.selectedTime + ', hasEvents: ' + (ev.events !== undefined && ev.events.length !== 0) + ', disabled: ' + ev.disabled);
509
+ };
510
+ ```
511
+ * onTitleChanged
512
+ The callback function triggered when the view title is changed
513
+ ``` html
514
+ <calendar ... (onTitleChanged)="onViewTitleChanged($event)"></calendar>
515
+ ```
516
+ ``` typescript
517
+ onViewTitleChanged = (title: string) => {
518
+ this.viewTitle = title;
519
+ };
520
+ ```
521
+ # View Customization Option
522
+ There are two ways to customize the look and feel. If you just want to simply change the color or size of certain element, you could override the styles of the predefined css classes. **CSS Customization** section lists some important css classes. If you need to change the layout of certain element, you could refer to the **Template Customization** part.
523
+
524
+ ## CSS Customization
525
+ The customized styles should be added in global.scss. Just adding in each components css file may not work due to the View Encapsulation.
526
+
527
+ * monthview-primary-with-event
528
+ The date that is in current month and having events
529
+
530
+ * monthview-secondary-with-event
531
+ The date that is in previous/next month and having events
532
+
533
+ * monthview-selected
534
+ The selected date
535
+
536
+ * monthview-current
537
+ The current date
538
+
539
+ * monthview-disabled
540
+ The disabled date
541
+
542
+ * weekview-with-event
543
+ The date having all day events, applied to the day header in week view
544
+
545
+ * weekview-current
546
+ The current date, applied to the day header in week view
547
+
548
+ * weekview-selected
549
+ The selected date, applied to the day header in week view
550
+
551
+ * weekview-allday-label
552
+ Applied to the all day label in week view
553
+
554
+ * dayview-allday-label
555
+ Applied to the all day label in day view
556
+
557
+ * calendar-hour-column
558
+ Applied to the hour column in both weekview and day view
559
+
560
+ * dayview-category-header (version: 2.4+)
561
+ Applied to the category section in day view
562
+
563
+ * dayview-category-header-item (version: 2.4+)
564
+ Applied to the category header item in day view
565
+
566
+ ## Template Customization
567
+
568
+ Note: For any css class appear in the customized template, you need to specify the styles by yourself. The styles defined in the calendar component won’t be applied because of the view encapsulation. You could refer to calendar.ts to get the definition of context types.
569
+
570
+ * monthviewDisplayEventTemplate
571
+ Type: TemplateRef\<IMonthViewDisplayEventTemplateContext\>
572
+ The template provides customized view for event displayed in the active monthview
573
+ ``` html
574
+ <ng-template #monthviewDisplayEventTemplate let-view="view" let-row="row" let-col="col">
575
+ {{view.dates[row*7+col].label}}
576
+ </ng-template>
577
+
578
+ <calendar ... [monthviewDisplayEventTemplate]="monthviewDisplayEventTemplate"></calendar>
579
+ ```
580
+ * monthviewInactiveDisplayEventTemplate
581
+ Type: TemplateRef\<IMonthViewDisplayEventTemplateContext\>
582
+ The template provides customized view for event displayed in the inactive monthview
583
+ ``` html
584
+ <ng-template #monthviewInactiveDisplayEventTemplate let-view="view" let-row="row" let-col="col">
585
+ {{view.dates[row*7+col].label}}
586
+ </ng-template>
587
+
588
+ <calendar ... [monthviewInactiveDisplayEventTemplate]="monthviewInactiveDisplayEventTemplate"></calendar>
589
+ ```
590
+ * monthviewEventDetailTemplate
591
+ Type: TemplateRef\<IMonthViewEventDetailTemplateContext\>
592
+ The template provides customized view for event detail section in the monthview
593
+ ``` html
594
+ <ng-template #monthviewEventDetailTemplate let-showEventDetail="showEventDetail" let-selectedDate="selectedDate" let-noEventsLabel="noEventsLabel">
595
+ ...
596
+ </ng-template>
597
+
598
+ <calendar ... [monthviewEventDetailTemplate]="monthviewEventDetailTemplate"></calendar>
599
+ ```
600
+ * weekviewHeaderTemplate (version >= 0.4.5)
601
+ Type: TemplateRef\<IDisplayWeekViewHeader\>
602
+ The template provides customized view for day header in the weekview
603
+ ``` html
604
+ <ng-template #weekviewHeaderTemplate let-viewDate="viewDate">
605
+ <div class="custom-day-header"> {{ viewDate.dayHeader }} </div>
606
+ </ng-template>
607
+
608
+ <calendar ... [weekviewHeaderTemplate]="weekviewHeaderTemplate"></calendar>
609
+ ```
610
+ * weekviewAllDayEventTemplate
611
+ Type: TemplateRef\<IDisplayAllDayEvent\>
612
+ The template provides customized view for all day event in the weekview
613
+ ``` html
614
+ <ng-template #weekviewAllDayEventTemplate let-displayEvent="displayEvent">
615
+ <div class="calendar-event-inner">{{displayEvent.event.title}}</div>
616
+ </ng-template>
617
+
618
+ <calendar ... [weekviewAllDayEventTemplate]="weekviewAllDayEventTemplate"></calendar>
619
+ ```
620
+ * weekviewNormalEventTemplate
621
+ Type: TemplateRef\<IDisplayEvent\>
622
+ The template provides customized view for normal event in the weekview
623
+
624
+ ``` html
625
+ <ng-template #weekviewNormalEventTemplate let-displayEvent="displayEvent">
626
+ <div class="calendar-event-inner">{{displayEvent.event.title}}</div>
627
+ </ng-template>
628
+
629
+ <calendar ... [weekviewNormalEventTemplate]="weekviewNormalEventTemplate"></calendar>
630
+ ```
631
+
632
+ * dayviewCategoryItemTemplate (version: 2.4+)
633
+ The template provides customized view for category item with categoryId and categoryName in the day view
634
+ ``` html
635
+ <ng-template #dayviewCategoryItemTemplate let-category="category">
636
+ {{ category.categoryName }}
637
+ </ng-template>
638
+
639
+ <calendar ... [dayviewCategoryItemTemplate]="dayviewCategoryItemTemplate"></calendar>
640
+ ```
641
+
642
+ * dayviewAllDayEventTemplate
643
+ Type: TemplateRef\<IDisplayAllDayEvent\>
644
+ The template provides customized view for all day event in the dayview
645
+ ``` html
646
+ <ng-template #dayviewAllDayEventTemplate let-displayEvent="displayEvent">
647
+ <div class="calendar-event-inner">{{displayEvent.event.title}}</div>
648
+ </ng-template>
649
+
650
+ <calendar ... [dayviewAllDayEventTemplate]="dayviewAllDayEventTemplate"></calendar>
651
+ ```
652
+
653
+ * dayviewNormalEventTemplate
654
+ Type: TemplateRef\<IDisplayEvent\>
655
+ The template provides customized view for normal event in the dayview
656
+
657
+ ``` html
658
+ <ng-template #dayviewNormalEventTemplate let-displayEvent="displayEvent">
659
+ <div class="calendar-event-inner">{{displayEvent.event.title}}</div>
660
+ </ng-template>
661
+
662
+ <calendar ... [dayviewNormalEventTemplate]="dayviewNormalEventTemplate"></calendar>
663
+ ```
664
+
665
+ * weekviewAllDayEventSectionTemplate (version >= 0.3)
666
+ Type: TemplateRef\<IWeekViewAllDayEventSectionTemplateContext\>
667
+ The template provides customized view for all day event section (table part) in the weekview
668
+
669
+ ``` html
670
+ <ng-template #weekviewAllDayEventSectionTemplate let-day="day" let-eventTemplate="eventTemplate">
671
+ <div [ngClass]="{'calendar-event-wrap': day.events}" *ngIf="day.events"
672
+ [ngStyle]="{height: 25*day.events.length+'px'}">
673
+ <div *ngFor="let displayEvent of day.events" class="calendar-event" tappable
674
+ (click)="onEventSelected(displayEvent.event)"
675
+ [ngStyle]="{top: 25*displayEvent.position+'px', width: 100*(displayEvent.endIndex-displayEvent.startIndex)+'%', height: '25px'}">
676
+ <ng-template [ngTemplateOutlet]="eventTemplate"
677
+ [ngTemplateOutletContext]="{displayEvent:displayEvent}">
678
+ </ng-template>
679
+ </div>
680
+ </div>
681
+ </ng-template>
682
+
683
+ <calendar ... [weekviewAllDayEventSectionTemplate]="weekviewAllDayEventSectionTemplate"></calendar>
684
+ ```
685
+
686
+ * weekviewNormalEventSectionTemplate (version >= 0.3)
687
+ Type: TemplateRef\<IWeekViewNormalEventSectionTemplateContext\>
688
+ The template provides customized view for normal event section (table part) in the weekview
689
+
690
+ ``` html
691
+ <ng-template #weekviewNormalEventSectionTemplate let-tm="tm" let-hourParts="hourParts" let-eventTemplate="eventTemplate">
692
+ <div [ngClass]="{'calendar-event-wrap': tm.events}" *ngIf="tm.events">
693
+ <div *ngFor="let displayEvent of tm.events" class="calendar-event" tappable
694
+ (click)="onEventSelected(displayEvent.event)"
695
+ [ngStyle]="{top: (37*displayEvent.startOffset/hourParts)+'px',left: 100/displayEvent.overlapNumber*displayEvent.position+'%', width: 100/displayEvent.overlapNumber+'%', height: 37*(displayEvent.endIndex -displayEvent.startIndex - (displayEvent.endOffset + displayEvent.startOffset)/hourParts)+'px'}">
696
+ <ng-template [ngTemplateOutlet]="eventTemplate"
697
+ [ngTemplateOutletContext]="{displayEvent:displayEvent}">
698
+ </ng-template>
699
+ </div>
700
+ </div>
701
+ </ng-template>
702
+
703
+ <calendar ... [weekviewNormalEventSectionTemplate]="weekviewNormalEventSectionTemplate"></calendar>
704
+ ```
705
+
706
+ * dayviewAllDayEventSectionTemplate (version >= 0.3)
707
+ Type: TemplateRef\<IDayViewAllDayEventSectionTemplateContext\>
708
+ The template provides customized view for all day event section (table part) in the dayview
709
+
710
+ ``` html
711
+ <ng-template #dayviewAllDayEventSectionTemplate let-allDayEvents="allDayEvents" let-eventTemplate="eventTemplate">
712
+ <div *ngFor="let displayEvent of allDayEvents; let eventIndex=index"
713
+ class="calendar-event" tappable
714
+ (click)="onEventSelected(displayEvent.event)"
715
+ [ngStyle]="{top: 25*eventIndex+'px',width: '100%',height:'25px'}">
716
+ <ng-template [ngTemplateOutlet]="eventTemplate"
717
+ [ngTemplateOutletContext]="{displayEvent:displayEvent}">
718
+ </ng-template>
719
+ </div>
720
+ </ng-template>
721
+
722
+ <calendar ... [dayviewAllDayEventSectionTemplate]="dayviewAllDayEventSectionTemplate"></calendar>
723
+ ```
724
+
725
+ * dayviewNormalEventSectionTemplate (version >= 0.3)
726
+ Type: TemplateRef\<IDayViewNormalEventSectionTemplateContext\>
727
+ The template provides customized view for normal event section (table part) in the dayview
728
+
729
+ ``` html
730
+ <ng-template #dayviewNormalEventSectionTemplate let-tm="tm" let-hourParts="hourParts" let-eventTemplate="eventTemplate">
731
+ <div [ngClass]="{'calendar-event-wrap': tm.events}" *ngIf="tm.events">
732
+ <div *ngFor="let displayEvent of tm.events" class="calendar-event" tappable
733
+ (click)="onEventSelected(displayEvent.event)"
734
+ [ngStyle]="{top: (37*displayEvent.startOffset/hourParts)+'px',left: 100/displayEvent.overlapNumber*displayEvent.position+'%', width: 100/displayEvent.overlapNumber+'%', height: 37*(displayEvent.endIndex -displayEvent.startIndex - (displayEvent.endOffset + displayEvent.startOffset)/hourParts)+'px'}">
735
+ <ng-template [ngTemplateOutlet]="eventTemplate"
736
+ [ngTemplateOutletContext]="{displayEvent:displayEvent}">
737
+ </ng-template>
738
+ </div>
739
+ </div>
740
+ </ng-template>
741
+
742
+ <calendar ... [dayviewNormalEventSectionTemplate]="dayviewNormalEventSectionTemplate"></calendar>
743
+ ```
744
+
745
+ * weekviewInactiveAllDayEventSectionTemplate (version >= 0.5)
746
+ Type: TemplateRef\<IWeekViewAllDayEventSectionTemplateContext\>
747
+ The template provides customized view for all day event section (table part) in the inactive weekview
748
+
749
+ ``` html
750
+ <ng-template #weekviewInactiveAllDayEventSectionTemplate let-day="day" let-eventTemplate="eventTemplate">
751
+ <div [ngClass]="{'calendar-event-wrap': day.events}" *ngIf="day.events"
752
+ [ngStyle]="{height: 25*day.events.length+'px'}">
753
+ <div *ngFor="let displayEvent of day.events" class="calendar-event" tappable
754
+ (click)="onEventSelected(displayEvent.event)"
755
+ [ngStyle]="{top: 25*displayEvent.position+'px', width: 100*(displayEvent.endIndex-displayEvent.startIndex)+'%', height: '25px'}">
756
+ <ng-template [ngTemplateOutlet]="eventTemplate"
757
+ [ngTemplateOutletContext]="{displayEvent:displayEvent}">
758
+ </ng-template>
759
+ </div>
760
+ </div>
761
+ </ng-template>
762
+
763
+        <calendar ... [weekviewInactiveAllDayEventSectionTemplate]="weekviewInactiveAllDayEventSectionTemplate"></calendar>
764
+ ```
765
+
766
+ * weekviewInactiveNormalEventSectionTemplate (version >= 0.5)
767
+ Type: TemplateRef\<IWeekViewNormalEventSectionTemplateContext\>
768
+ The template provides customized view for normal event section (table part) in the inactive weekview
769
+
770
+ ``` html
771
+ <ng-template #weekviewInactiveNormalEventSectionTemplate let-tm="tm" let-hourParts="hourParts" let-eventTemplate="eventTemplate">
772
+ <div [ngClass]="{'calendar-event-wrap': tm.events}" *ngIf="tm.events">
773
+ <div *ngFor="let displayEvent of tm.events" class="calendar-event" tappable
774
+ (click)="onEventSelected(displayEvent.event)"
775
+ [ngStyle]="{top: (37*displayEvent.startOffset/hourParts)+'px',left: 100/displayEvent.overlapNumber*displayEvent.position+'%', width: 100/displayEvent.overlapNumber+'%', height: 37*(displayEvent.endIndex -displayEvent.startIndex - (displayEvent.endOffset + displayEvent.startOffset)/hourParts)+'px'}">
776
+ <ng-template [ngTemplateOutlet]="eventTemplate"
777
+ [ngTemplateOutletContext]="{displayEvent:displayEvent}">
778
+ </ng-template>
779
+ </div>
780
+ </div>
781
+ </ng-template>
782
+
783
+        <calendar ... [weekviewInactiveNormalEventSectionTemplate]="weekviewInactiveNormalEventSectionTemplate"></calendar>
784
+ ```
785
+
786
+ * dayviewInactiveAllDayEventSectionTemplate (version >= 0.5)
787
+ Type: TemplateRef\<IDayViewAllDayEventSectionTemplateContext\>
788
+ The template provides customized view for all day event section (table part) in the inactive dayview
789
+
790
+ ``` html
791
+ <ng-template #dayviewInactiveAllDayEventSectionTemplate let-allDayEvents="allDayEvents" let-eventTemplate="eventTemplate">
792
+ <div *ngFor="let displayEvent of allDayEvents; let eventIndex=index"
793
+ class="calendar-event" tappable
794
+ (click)="onEventSelected(displayEvent.event)"
795
+ [ngStyle]="{top: 25*eventIndex+'px',width: '100%',height:'25px'}">
796
+ <ng-template [ngTemplateOutlet]="eventTemplate"
797
+ [ngTemplateOutletContext]="{displayEvent:displayEvent}">
798
+ </ng-template>
799
+ </div>
800
+ </ng-template>
801
+
802
+        <calendar ... [dayviewInactiveAllDayEventSectionTemplate]="dayviewInactiveAllDayEventSectionTemplate"></calendar>
803
+ ```
804
+
805
+ * dayviewInactiveNormalEventSectionTemplate (version >= 0.5)
806
+ Type: TemplateRef\<IDayViewNormalEventSectionTemplateContext\>
807
+ The template provides customized view for normal event section (table part) in the inactive dayview
808
+
809
+ ``` html
810
+ <ng-template #dayviewInactiveNormalEventSectionTemplate let-tm="tm" let-hourParts="hourParts" let-eventTemplate="eventTemplate">
811
+ <div [ngClass]="{'calendar-event-wrap': tm.events}" *ngIf="tm.events">
812
+ <div *ngFor="let displayEvent of tm.events" class="calendar-event" tappable
813
+ (click)="onEventSelected(displayEvent.event)"
814
+ [ngStyle]="{top: (37*displayEvent.startOffset/hourParts)+'px',left: 100/displayEvent.overlapNumber*displayEvent.position+'%', width: 100/displayEvent.overlapNumber+'%', height: 37*(displayEvent.endIndex -displayEvent.startIndex - (displayEvent.endOffset + displayEvent.startOffset)/hourParts)+'px'}">
815
+ <ng-template [ngTemplateOutlet]="eventTemplate"
816
+ [ngTemplateOutletContext]="{displayEvent:displayEvent}">
817
+ </ng-template>
818
+ </div>
819
+ </div>
820
+ </ng-template>
821
+
822
+        <calendar ... [dayviewInactiveNormalEventSectionTemplate]="dayviewInactiveNormalEventSectionTemplate"></calendar>
823
+ ```
824
+
825
+
826
+ # EventSource
827
+
828
+ EventSource is an array of event object which contains at least below fields:
829
+
830
+ * title
831
+ Type: `string`
832
+
833
+ * startTime
834
+ Type: `Date`
835
+ If allDay is set to true, the startTime has to be as a UTC date which time is set to 0:00 AM, because in an allDay event, only the date is considered, the exact time or timezone doesn't matter.
836
+ For example, if an allDay event starting from 2014-05-09, then startTime is
837
+
838
+ ``` javascript
839
+ var startTime = new Date(Date.UTC(2014, 4, 8));
840
+ ```
841
+
842
+ * endTime
843
+ Type: `Date`
844
+ If allDay is set to true, the startTime has to be as a UTC date which time is set to 0:00 AM, because in an allDay event, only the date is considered, the exact time or timezone doesn't matter.
845
+ For example, if an allDay event ending to 2014-05-10, then endTime is
846
+ ``` javascript
847
+ var endTime = new Date(Date.UTC(2014, 4, 9));
848
+ ```
849
+ * allDay
850
+ Type: `boolean`
851
+ Indicates the event is allDay event or regular event
852
+
853
+ * category (optional)
854
+ Type: `string`
855
+ Indicates which category the event belongs to. If the value is specified but not one of `dayviewCategorySource`, the event will not display in category view.
856
+
857
+ **Note** The calendar only watches for the eventSource reference for performance consideration. That means only you manually reassign the eventSource value, the calendar gets notified, and this is usually fit to the scenario when the range is changed, you load a new data set from the backend. In case you want to manually insert/remove/update the element in the eventSource array, you can call [instance method](#instance-methods) ‘loadEvents’ event to notify the calendar manually.
858
+
859
+ # Instance Methods
860
+ * loadEvents
861
+ When this method is called, the calendar will be forced to reload the events in the eventSource array. This is only necessary when you directly modify the element in the eventSource array.
862
+
863
+ ``` typescript
864
+ import { CalendarComponent } from "ionic2-calendar";
865
+
866
+ @Component({
867
+ selector: 'page-home',
868
+ templateUrl: 'home.html'
869
+ })
870
+ export class HomePage {
871
+ @ViewChild(CalendarComponent, null) myCalendar:CalendarComponent;
872
+ eventSource;
873
+ …
874
+ loadEvents: function() {
875
+ this.eventSource.push({
876
+ title: 'test',
877
+ startTime: startTime,
878
+ endTime: endTime,
879
+ allDay: false
880
+ });
881
+ this.myCalendar.loadEvents();
882
+ }
883
+ }
884
+ ```
885
+
886
+ * slideNext (version >= 0.5)
887
+ Slide the calendar to the next date range.
888
+
889
+ ``` typescript
890
+ import { CalendarComponent } from "ionic2-calendar";
891
+
892
+ @Component({
893
+ selector: 'page-home',
894
+ templateUrl: 'home.html'
895
+ })
896
+ export class HomePage {
897
+ @ViewChild(CalendarComponent, null) myCalendar:CalendarComponent;
898
+ …
899
+ slideNext: function() {
900
+ this.myCalendar.slideNext();
901
+ }
902
+ }
903
+ ```
904
+
905
+ * slidePrev (version >= 0.5)
906
+ Slide the calendar to the previous date range.
907
+
908
+ ``` typescript
909
+ import { CalendarComponent } from "ionic2-calendar";
910
+
911
+ @Component({
912
+ selector: 'page-home',
913
+ templateUrl: 'home.html'
914
+ })
915
+ export class HomePage {
916
+ @ViewChild(CalendarComponent, null) myCalendar:CalendarComponent;
917
+ …
918
+ slidePrev: function() {
919
+ this.myCalendar.slidePrev();
920
+ }
921
+ }
922
+ ```
923
+
924
+ * update (version >= 0.6.5)
925
+ Update the underlying slides.
926
+
927
+ ``` typescript
928
+ import { CalendarComponent } from "ionic2-calendar";
929
+
930
+ @Component({
931
+ selector: 'page-home',
932
+ templateUrl: 'home.html'
933
+ })
934
+ export class HomePage {
935
+ @ViewChild(CalendarComponent, null) myCalendar:CalendarComponent;
936
+ …
937
+ slidePrev: function() {
938
+ this.myCalendar.update();
939
+ }
940
+ }
941
+ ```
942
+
943
+ # Localization
944
+ You could use *locale* option to achieve the localization.
945
+ If locale option is not specified, the calendar will use the LOCALE_ID set at the module level.
946
+ By default, the LOCALE_ID is **en-US**. You can override it in the module as below. If you pass **undefined**, the LOCALE_ID will be detected using the browser language setting. But using explicit value is recommended, as browser has different level of localization support.
947
+ Note that the event detail section in the month view doesn't support *locale* option, only LOCALE_ID takes effect. This is because it uses DatePipe in html directly. You could easily leverage customized event detail template to switch to other locale.
948
+
949
+ ``` typescript
950
+ import { NgModule, LOCALE_ID } from '@angular/core';
951
+
952
+ @NgModule({
953
+ …
954
+ providers: [
955
+ { provide: LOCALE_ID, useValue: 'zh-CN' }
956
+ ]
957
+ })
958
+ ```
959
+
960
+ For version 0.4.x+ which depends on Ionic 3.9.2+ and Angular 5.0+, locale module needs to be registered explicitly in module file as below.
961
+ ``` typescript
962
+ import { registerLocaleData } from '@angular/common';
963
+ import localeZh from '@angular/common/locales/zh';
964
+ registerLocaleData(localeZh);
965
+
966
+ ```
967
+
968
+ If you want to change the locale dynamically, you should use *locale* option instead of LOCALE_ID.
969
+
970
+ # Performance Tuning
971
+ In the CPU profile, the default Intl based localization code occupies a big portion of the execution time. If you don’t need localization on certain parts, you can use the custom dateFormatter to override the date transform method. For example, the date in month view usually doesn’t require localization, you could use below code to just display the date part. If the month view day header doesn’t need to include the date, you could also use a string array containing static labels to save the date calculation.
972
+
973
+ ``` html
974
+ <calendar ... [dateFormatter]="calendar.dateFormatter"></calendar>
975
+ ```
976
+ ``` typescript
977
+ calendar = {
978
+ dateFormatter: {
979
+ formatMonthViewDay: function(date:Date) {
980
+ return date.getDate().toString();
981
+ }
982
+ }
983
+ };
984
+ ```
985
+
986
+ # Known issue (No longer exists in version 1.0.x)
987
+ This component updates the ion-slide dynamically so that only 3 looped slides are needed.
988
+ The ion-slide in Ionic2 uses Swiper. It seems in the Swiper implementation, the next slide after the end of looped slide is a separate cached slide, instead of the first slide.
989
+ I can't find out a way to force refresh that cached slide, so you will notice that when sliding from the third month to the forth month, the preview month is not the forth month, but the first month.
990
+ Once the sliding is over, the slide will be forced to render the forth month.
991
+
992
+ # Common Questions
993
+ * Error: Cannot find module "intl"
994
+ Answer: This calendar has dependency on 'Intl'. Run *npm install intl@1.2.5* to install the dependency
995
+
996
+ * Error: Cannot read property 'getFullYear' of undefined
997
+ Answer: If you bind currentDate like this: [currentDate]="calendar.currentDate". You need to assign calendar.currentDate a valid Date object
998
+
999
+ * How to switch the calendar to previous/next month programmatically?
1000
+ Answer: You can change currentDate to the date in previous/next month. You could also call the instance method slideNext/slidePrev.
1001
+
1002
+ * Error: Cannot read property 'dayHeaders' of undefined
1003
+ Answer: Take a look at the Localization section. For version 0.4.x+, you need to manually register the locale.
1004
+
1005
+ * Error: TypeError: event_1.startTime.getTime is not a function
1006
+ Answer: This is due to the startTime field of the event object is not a valid Date object. Be aware that different browser has different implementation of new Date() constructor. Some date string format may not be supported. It is recommended to use millisecond or year/month/date parameters.
1007
+
1008
+ * Error: How to override css
1009
+ Answer: By default, the css applied on each component is view encapsulated, for example, .table-bordered[_ngcontent-jto-c5]. You need to remove the encapsulated part.
1010
+ ```css
1011
+ .table-bordered[_ngcontent-jto-c5] {
1012
+ border: 1px solid #ddd !important;
1013
+ }
1014
+ ```