Closed kylecannon closed 8 years ago
Hi, thanks for the contribution!
This going to break a lot of existing code (not everyone uses browserify or webpack).
Did you try requiring moment-timezone
before requiring angular-moment
and see if this does the trick?
I did. I've spent about two hours or more trying to come up with a workaround before coming to this solution. However, if others aren't webpack or browserify this doesn't affect them at all as it doesn't change the global injection (only amd and commonJS style)
The tests still pass that were written for the global style includes since it's injected via a script tag.
There are also require.js users. I believe this can still be worked around by using angular.js dependency injection and overriding the moment
constant with a suitable implementation (e.g. the one returned by requiring moment-timezone
).
Can you please have a look at it and see if this does the trick?
Well don't I feel like an idiot... one... simple... line of code.
Thank you!
Also, for some weird reason beta 5 doesn't throw the error that I am seeing in beta 4. So I will upgrade to beta 5 and also keep ngModule.constant('moment', require('moment-timezone'));
there as well incase.
Also, I appreciate the help and the fast response. Great library!
Thanks Kyle!
Any chance you can send a PR with an update to README.md
in favor of future users with the same need?
Is there any way of doing this without require?
moment-timezone
replacesmoment
when installed via npm (installation instructions here). Due to the require statements asking formoment
instead ofmoment-timezone
, it's impossible to getmoment.tz
to be defined. Changing the package.json dependency from moment to moment-timezone brings back expected functionality when using tools such as browserify and webpack.