From a9f71a8f2e0d646d76d9538bfa8f5764d5f2d166 Mon Sep 17 00:00:00 2001 From: Dale 'Ducky' Lotts Date: Sun, 8 Apr 2018 11:18:42 -0500 Subject: [PATCH] fix(aot): AOT build failing after adding string data support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ERROR in ../angular-bootstrap-datetimepicker/angular-bootstrap-datetimepicker.ts(104,9): Error during template compile of 'DlDateTimePickerStringModule’. Function calls are not supported in decorators but 'localeData' was called. Fixes #429 --- .../dl-date-time-picker.module.ts | 31 ++++++++++++------- src/lib/dl-date-time-picker/public-api.ts | 1 + 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/src/lib/dl-date-time-picker/dl-date-time-picker.module.ts b/src/lib/dl-date-time-picker/dl-date-time-picker.module.ts index 2ba6441e..40b71375 100644 --- a/src/lib/dl-date-time-picker/dl-date-time-picker.module.ts +++ b/src/lib/dl-date-time-picker/dl-date-time-picker.module.ts @@ -39,6 +39,24 @@ import * as _moment from 'moment'; **/ const moment = _moment; +/** + * `Moment`'s long date format `lll` used as the default output format + * for string date's + */ +export const LONG_DATE_FORMAT = moment.localeData().longDateFormat('lll'); + +/** + * Default input format's used by `DlDateAdapterString` + */ +export const INPUT_FORMATS = [ + 'YYYY-MM-DDTHH:mm', + 'YYYY-MM-DDTHH:mm:ss', + 'YYYY-MM-DDTHH:mm:ss.SSS', + 'YYYY-MM-DD', + LONG_DATE_FORMAT, + moment.ISO_8601 +]; + /** * Import this module to supply your own `DateAdapter` provider. * @internal @@ -99,17 +117,8 @@ export class DlDateTimePickerMomentModule { imports: [DlDateTimePickerModule], exports: [DlDateTimePickerComponent], providers: [ - { - provide: DL_STRING_DATE_INPUT_FORMATS, useValue: [ - moment.localeData().longDateFormat('lll'), - 'YYYY-MM-DDTHH:mm', - 'YYYY-MM-DDTHH:mm:ss', - 'YYYY-MM-DDTHH:mm:ss.SSS', - 'YYYY-MM-DD', - moment.ISO_8601 - ] - }, - {provide: DL_STRING_DATE_OUTPUT_FORMAT, useValue: moment.localeData().longDateFormat('lll')}, + {provide: DL_STRING_DATE_INPUT_FORMATS, useValue: INPUT_FORMATS}, + {provide: DL_STRING_DATE_OUTPUT_FORMAT, useValue: LONG_DATE_FORMAT}, {provide: DlDateAdapter, useClass: DlDateAdapterString} ], }) diff --git a/src/lib/dl-date-time-picker/public-api.ts b/src/lib/dl-date-time-picker/public-api.ts index f06f1651..abeed8d3 100644 --- a/src/lib/dl-date-time-picker/public-api.ts +++ b/src/lib/dl-date-time-picker/public-api.ts @@ -11,6 +11,7 @@ export * from './dl-date-adapter'; export * from './dl-date-adapter-moment'; export * from './dl-date-adapter-native'; export * from './dl-date-adapter-number'; +export * from './dl-date-adapter-string'; export * from './dl-date-time-picker-change'; export * from './dl-date-time-picker-model'; export * from './dl-date-time-picker.component';