Skip to content

Commit

Permalink
fix(aot): AOT build failing after adding string data support
Browse files Browse the repository at this point in the history
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
  • Loading branch information
dalelotts committed Apr 8, 2018
1 parent f645ffb commit a9f71a8
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 11 deletions.
31 changes: 20 additions & 11 deletions src/lib/dl-date-time-picker/dl-date-time-picker.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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}
],
})
Expand Down
1 change: 1 addition & 0 deletions src/lib/dl-date-time-picker/public-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down

0 comments on commit a9f71a8

Please sign in to comment.