-
Notifications
You must be signed in to change notification settings - Fork 236
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
TypeError: moment is not a function #5
Comments
I'll check that later today and let you know. |
I made some fixes and published new version (0.4.0) to npm. Please check if it works for you. Also, try including as |
Hi Jan, thanks for looking into this. Unfortunately I still get the same error with 0.4.0. |
Here is the sample. No problem, this should be working so I will take a look and tested before publishing later today. |
Hey Jan, I just found out I was still using angular2 beta0 - after updating to beta2 the error is gone! |
Cool! Glad you resolved it. |
I know this issue is marked as closed but I too am getting moment is not a function also. Updating to beta2 as mention by @mkreis did not work for me. Here is my System.configuration
|
Thanks for noticing guys. I will check into this and make a fix today. |
Hi guys! |
Or try installing moment separately with |
I'll keep an eye on any updates thanks 👍 npm install moment didn't work for me. |
Guys, I managed to solve this. Moment is now included within the bundles. Please see the readme. |
Any way to use it on an already started project? |
Are you using SystemJS? On Sunday, 7 February 2016, Boban Stojanovski notifications@github.com
|
yes i am ... but as u know i am getting the error moment is not a function. Anyway nice work on the control |
Ok, no problem, you can install it with nom install ng2-datepicker. On Sunday, 7 February 2016, Boban Stojanovski notifications@github.com
|
Then include the script into your index.html as On Sunday, 7 February 2016, Jan Kuri jkuri88@gmail.com wrote:
|
I created a new test project following the 5min tutorial on Angular.io Now im getting "EXCEPTION: No value accessor for '' in [test in AppComponent@3:16]" `import {Component} from 'angular2/core'; class Test { @component({
} |
In orded to get it working in 5 minutes use the commands I provided in |
May 25/2016: I'd like to add a working configuration. I ** don't ** use angular-cli. Here's how to get ng2-datepicker working with moment.js. I also use moment.js elsewhere in my code. My code is originally typescript, as you might expect. index.html snippet at the bottom. Note that I simply "map" the locations for moment.js and ng2-datepicker.js. And for ng2-datepicker, you have to get down to embedded source because the top level file of the same name is not compatible with simply loading it. Then I call the SystemJS import method on the label, and it uses the map value. In my typescript component, I simply: import {DatePicker} from 'ng2-datepicker'; and use the imported component per angular2 specifications. Doing this is compatible with the moment loading that occurs within ng2-datepicker. If I need to use moment elsewhere I do this: import moment from 'moment' Et voila...it all works. index.html script snippet
|
I've got the same problem, all the solutions mentioned in this thread did not work. Finally I got it to work by modifying the import statement in ng2-datepicker.ts:
instead of
@jkuri can you maybe fix it in your sources? I'm using angular rc5 with SystemJS Here is the relevant part in my index.html (I removed all the mappings which are not relevant in this thread):
|
Hey @tryptophane, I need to check first if that works with other configurations too. If so, I will update it. |
I've been following the instruction to use the date picker, but the unfortunately the component throws the following exception:
angular2.dev.js:23514 TypeError: moment is not a function
at DatePicker.init (ng2-datepicker.ts:172)
at new DatePicker (ng2-datepicker.ts:41)
at angular2.dev.js:1380
at Injector._instantiate (angular2.dev.js:11923)
Any clue what could be the cause?
Moment.js included using the SystemJS map (like the date picker).
Thanks!
The text was updated successfully, but these errors were encountered: