Skip to content
This repository has been archived by the owner on Mar 2, 2018. It is now read-only.

Unable to use with moment loaded as an import #222

Open
jbouzekri opened this issue Nov 8, 2017 · 0 comments
Open

Unable to use with moment loaded as an import #222

jbouzekri opened this issue Nov 8, 2017 · 0 comments

Comments

@jbouzekri
Copy link

Steps to reproduce and a minimal demo

I could not do a plunkr. I don't know how to do it with webpack loader and typescript support. Sorry.

These are the steps to reproduce it :

init a simple AngularCLI project :

ng new myapp
npm install --save moment
npm install @ngui/datetime-picker --save

In AppModule, add :

import * as moment from 'moment';
import 'moment/min/locales';

In AppComponent html file, add :

<input type="text" ngui-datetime-picker name="start_date" [(ngModel)]="start_date" id="form-startdate" class="form-control" date-format="DD-MM-YYYY hh:mm:ss" required />

The ngModel bindings works but the field stays empty. I think the issue is here :
https://github.com/ng2-ui/datetime-picker/blob/master/src/datetime.ts#L80
You are waiting for a global moment library and not one imported using an import declaration.

Current behavior

The date-format attribute is ignored as it does not find the moment library which is loaded as an import and not a global.

Expected/desired behavior

Loading the moment library as an import should be the recommended way of handling it.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant