Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moment is not a function DateFormatter #252

Closed
manuelCorredor opened this issue Mar 8, 2016 · 3 comments
Closed

Moment is not a function DateFormatter #252

manuelCorredor opened this issue Mar 8, 2016 · 3 comments

Comments

@manuelCorredor
Copy link

Hi, Iḿ having a lot of trouble with moment js, I have already installed moment js as a dependency and installed the typings too (ambient and dev).

My code works fine (I'm not using the datepicker component), but sadly I get the next error:

TypeError: moment is not a function at DateFormatter.format

I've already read and follow the instructions in the main page and also in:

http://stackoverflow.com/questions/35166168/how-to-use-moment-js-library-in-angular-2-typescript-app

my system.js config look like this :

System.config({
transpiler: 'typescript',
typescriptOptions: { emitDecoratorMetadata: true },
packages: {
"app": {
"defaultExtension": "ts"
},
"node_modules/ng2-bootstrap": {
"defaultExtension": "ts"
},
},
map: {
moment: 'node_modules/moment/moment.js'
},
paths: {
"ng2-bootstrap/ng2-bootstrap": "node_modules/ng2-bootstrap/ng2-bootstrap"
}
});

can you help me ?

@valorkin
Copy link
Member

known issue, will be fixed in terms of #324

@HJHorst
Copy link

HJHorst commented Mar 29, 2016

I got it working by changing the first line of date-formatter.ts from
import * as moment from 'moment';
to
import moment from 'moment';

@srghma
Copy link

srghma commented Sep 17, 2016

Have the same issue when import DatepickerModule, "ng2-bootstrap": "^1.1.5", moment: 2.15.0, project was generated by angular-cli 1.0.0-beta.14, angular 2.0.0

angular-cli.json (that`s all configuration)

.....
"scripts": [
  "../node_modules/jquery/dist/jquery.js",
  "../node_modules/bootstrap/dist/js/bootstrap.js",
  "../node_modules/moment/moment.js"
],

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

No branches or pull requests

4 participants