Skip to content

Commit a9f71a8

Browse files
committed
fix(aot): AOT build failing after adding string data support
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
1 parent f645ffb commit a9f71a8

File tree

2 files changed

+21
-11
lines changed

2 files changed

+21
-11
lines changed

src/lib/dl-date-time-picker/dl-date-time-picker.module.ts

+20-11
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,24 @@ import * as _moment from 'moment';
3939
**/
4040
const moment = _moment;
4141

42+
/**
43+
* `Moment`'s long date format `lll` used as the default output format
44+
* for string date's
45+
*/
46+
export const LONG_DATE_FORMAT = moment.localeData().longDateFormat('lll');
47+
48+
/**
49+
* Default input format's used by `DlDateAdapterString`
50+
*/
51+
export const INPUT_FORMATS = [
52+
'YYYY-MM-DDTHH:mm',
53+
'YYYY-MM-DDTHH:mm:ss',
54+
'YYYY-MM-DDTHH:mm:ss.SSS',
55+
'YYYY-MM-DD',
56+
LONG_DATE_FORMAT,
57+
moment.ISO_8601
58+
];
59+
4260
/**
4361
* Import this module to supply your own `DateAdapter` provider.
4462
* @internal
@@ -99,17 +117,8 @@ export class DlDateTimePickerMomentModule {
99117
imports: [DlDateTimePickerModule],
100118
exports: [DlDateTimePickerComponent],
101119
providers: [
102-
{
103-
provide: DL_STRING_DATE_INPUT_FORMATS, useValue: [
104-
moment.localeData().longDateFormat('lll'),
105-
'YYYY-MM-DDTHH:mm',
106-
'YYYY-MM-DDTHH:mm:ss',
107-
'YYYY-MM-DDTHH:mm:ss.SSS',
108-
'YYYY-MM-DD',
109-
moment.ISO_8601
110-
]
111-
},
112-
{provide: DL_STRING_DATE_OUTPUT_FORMAT, useValue: moment.localeData().longDateFormat('lll')},
120+
{provide: DL_STRING_DATE_INPUT_FORMATS, useValue: INPUT_FORMATS},
121+
{provide: DL_STRING_DATE_OUTPUT_FORMAT, useValue: LONG_DATE_FORMAT},
113122
{provide: DlDateAdapter, useClass: DlDateAdapterString}
114123
],
115124
})

src/lib/dl-date-time-picker/public-api.ts

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export * from './dl-date-adapter';
1111
export * from './dl-date-adapter-moment';
1212
export * from './dl-date-adapter-native';
1313
export * from './dl-date-adapter-number';
14+
export * from './dl-date-adapter-string';
1415
export * from './dl-date-time-picker-change';
1516
export * from './dl-date-time-picker-model';
1617
export * from './dl-date-time-picker.component';

0 commit comments

Comments
 (0)