diff --git a/demos/demo-app.module.ts b/demos/demo-app.module.ts index 763d8ef55..f66f38caa 100644 --- a/demos/demo-app.module.ts +++ b/demos/demo-app.module.ts @@ -263,6 +263,13 @@ import { DemoModule as DefaultDemoModule } from './demo-modules/kitchen-sink/mod label: 'No events label' } }, + { + path: 'moment', + loadChildren: './demo-modules/moment/module#DemoModule', + data: { + label: 'Use moment' + } + }, { path: '**', redirectTo: 'kitchen-sink' diff --git a/demos/demo-modules/i18n/template.html b/demos/demo-modules/i18n/template.html index 2879ee865..9c46837b3 100644 --- a/demos/demo-modules/i18n/template.html +++ b/demos/demo-modules/i18n/template.html @@ -27,4 +27,4 @@ [events]="events" [locale]="locale"> - \ No newline at end of file + diff --git a/demos/demo-modules/moment/component.ts b/demos/demo-modules/moment/component.ts new file mode 100644 index 000000000..a18673c2c --- /dev/null +++ b/demos/demo-modules/moment/component.ts @@ -0,0 +1,24 @@ +import { Component, ChangeDetectionStrategy } from '@angular/core'; +import { CalendarEvent, DAYS_OF_WEEK } from 'angular-calendar'; +import moment from 'moment'; + +// weekStartsOn option is ignored when using moment, as it needs to be configured globally for the moment locale +moment.updateLocale('en', { + week: { + dow: DAYS_OF_WEEK.MONDAY, + doy: 0 + } +}); + +@Component({ + selector: 'mwl-demo-component', + changeDetection: ChangeDetectionStrategy.OnPush, + templateUrl: 'template.html' +}) +export class DemoComponent { + view: string = 'month'; + + viewDate: Date = new Date(); + + events: CalendarEvent[] = []; +} diff --git a/demos/demo-modules/moment/module.ts b/demos/demo-modules/moment/module.ts new file mode 100644 index 000000000..8fc044aed --- /dev/null +++ b/demos/demo-modules/moment/module.ts @@ -0,0 +1,43 @@ +import { NgModule } from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { RouterModule } from '@angular/router'; +import { + CalendarDateFormatter, + CalendarModule, + CalendarMomentDateFormatter, + CalendarUtils, + MOMENT +} from 'angular-calendar'; +import moment from 'moment'; +import { DemoUtilsModule } from '../demo-utils/module'; +import { DemoComponent } from './component'; +import { CalendarUtilsMoment } from 'angular-calendar/calendar-utils/moment'; + +@NgModule({ + imports: [ + CommonModule, + CalendarModule.forRoot( + { + provide: CalendarUtils, + useClass: CalendarUtilsMoment + }, + { + dateFormatter: { + provide: CalendarDateFormatter, + useClass: CalendarMomentDateFormatter + } + } + ), + DemoUtilsModule, + RouterModule.forChild([{ path: '', component: DemoComponent }]) + ], + declarations: [DemoComponent], + exports: [DemoComponent], + providers: [ + { + provide: MOMENT, + useValue: moment + } + ] +}) +export class DemoModule {} diff --git a/demos/demo-modules/moment/sources.ts b/demos/demo-modules/moment/sources.ts new file mode 100644 index 000000000..f6e7fbf15 --- /dev/null +++ b/demos/demo-modules/moment/sources.ts @@ -0,0 +1,23 @@ +export const sources = [ + { + filename: 'component.ts', + contents: { + raw: require('!!raw-loader!./component'), + highlighted: require('!!raw-loader!highlightjs-loader?lang=typescript!./component') + } + }, + { + filename: 'template.html', + contents: { + raw: require('!!raw-loader!./template.html'), + highlighted: require('!!raw-loader!highlightjs-loader?lang=xml!./template.html') + } + }, + { + filename: 'module.ts', + contents: { + raw: require('!!raw-loader!./module'), + highlighted: require('!!raw-loader!highlightjs-loader?lang=typescript!./module') + } + } +]; diff --git a/demos/demo-modules/moment/template.html b/demos/demo-modules/moment/template.html new file mode 100644 index 000000000..6062a7ba5 --- /dev/null +++ b/demos/demo-modules/moment/template.html @@ -0,0 +1,27 @@ +