@@ -3,7 +3,12 @@ import {
3
3
ChangeDetectionStrategy ,
4
4
ViewEncapsulation
5
5
} from '@angular/core' ;
6
- import { CalendarEvent , CalendarMonthViewDay } from 'angular-calendar' ;
6
+ import {
7
+ CalendarEvent ,
8
+ CalendarMonthViewBeforeRenderEvent ,
9
+ CalendarWeekViewBeforeRenderEvent ,
10
+ CalendarDayViewBeforeRenderEvent
11
+ } from 'angular-calendar' ;
7
12
8
13
@Component ( {
9
14
selector : 'mwl-demo-component' ,
@@ -12,8 +17,8 @@ import { CalendarEvent, CalendarMonthViewDay } from 'angular-calendar';
12
17
templateUrl : 'template.html' ,
13
18
styles : [
14
19
`
15
- .odd-cell {
16
- background-color: pink !important;
20
+ .bg-pink {
21
+ background-color: hotpink !important;
17
22
}
18
23
`
19
24
]
@@ -25,11 +30,38 @@ export class DemoComponent {
25
30
26
31
events : CalendarEvent [ ] = [ ] ;
27
32
28
- beforeMonthViewRender ( { body } : { body : CalendarMonthViewDay [ ] } ) : void {
29
- body . forEach ( day => {
30
- if ( day . date . getDate ( ) % 2 === 1 && day . inMonth ) {
31
- day . cssClass = 'odd-cell' ;
33
+ beforeMonthViewRender ( renderEvent : CalendarMonthViewBeforeRenderEvent ) : void {
34
+ renderEvent . body . forEach ( day => {
35
+ const dayOfMonth = day . date . getDate ( ) ;
36
+ if ( dayOfMonth > 5 && dayOfMonth < 10 && day . inMonth ) {
37
+ day . cssClass = 'bg-pink' ;
32
38
}
33
39
} ) ;
34
40
}
41
+
42
+ beforeWeekViewRender ( renderEvent : CalendarWeekViewBeforeRenderEvent ) {
43
+ renderEvent . hourColumns . forEach ( hourColumn => {
44
+ hourColumn . hours . forEach ( hour => {
45
+ hour . segments . forEach ( segment => {
46
+ if (
47
+ segment . date . getHours ( ) >= 2 &&
48
+ segment . date . getHours ( ) <= 5 &&
49
+ segment . date . getDay ( ) === 2
50
+ ) {
51
+ segment . cssClass = 'bg-pink' ;
52
+ }
53
+ } ) ;
54
+ } ) ;
55
+ } ) ;
56
+ }
57
+
58
+ beforeDayViewRender ( renderEvent : CalendarDayViewBeforeRenderEvent ) {
59
+ renderEvent . body . hourGrid . forEach ( hour => {
60
+ hour . segments . forEach ( ( segment , index ) => {
61
+ if ( segment . date . getHours ( ) >= 2 && segment . date . getHours ( ) <= 5 ) {
62
+ segment . cssClass = 'bg-pink' ;
63
+ }
64
+ } ) ;
65
+ } ) ;
66
+ }
35
67
}
0 commit comments