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

Unable to use with moment loaded as an import #222

@jbouzekri

Description

@jbouzekri

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions