Skip to content

Commit

Permalink
feat: allow overriding of providers via the calendar modules forRoot …
Browse files Browse the repository at this point in the history
…method

Closes #205
  • Loading branch information
Matt Lewis committed May 14, 2017
1 parent 32e9c5b commit 847212e
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/calendar.module.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { NgModule, ModuleWithProviders } from '@angular/core';
import { NgModule, ModuleWithProviders, Provider } from '@angular/core';
import { CommonModule } from '@angular/common';
import { ResizableModule } from 'angular-resizable-element';
import { DragAndDropModule, DraggableHelper } from 'angular-draggable-droppable';
Expand Down Expand Up @@ -26,6 +26,12 @@ import { CalendarEventTitleFormatter } from './providers/calendarEventTitleForma
import { CalendarDateFormatter } from './providers/calendarDateFormatter.provider';
import { CalendarUtils } from './providers/calendarUtils.provider';

export interface CalendarModuleConfig {
eventTitleFormatter?: Provider;
dateFormatter?: Provider;
utils?: Provider;
}

/**
* The main module of this library. Example usage:
*
Expand Down Expand Up @@ -99,15 +105,15 @@ import { CalendarUtils } from './providers/calendarUtils.provider';
})
export class CalendarModule {

static forRoot(): ModuleWithProviders {
static forRoot(config: CalendarModuleConfig = {}): ModuleWithProviders {

return {
ngModule: CalendarModule,
providers: [
CalendarEventTitleFormatter,
CalendarDateFormatter,
DraggableHelper,
CalendarUtils
config.eventTitleFormatter || CalendarEventTitleFormatter,
config.dateFormatter || CalendarDateFormatter,
config.utils || CalendarUtils
]
};

Expand Down

0 comments on commit 847212e

Please sign in to comment.