urish / angular-moment

Moment.JS directives for Angular.JS (timeago and more)
MIT License
2.6k stars 397 forks source link

Adds an additional typeof check for the global.moment instance #295

Closed schester44 closed 6 years ago

schester44 commented 6 years ago

It is possible for the global object to exist but global.moment to not exist which results in Error: Moment cannot by found by angular-moment!

This happens in edge cases such as when using QtWebKit where a global object is defined but global.moment is undefined. Because of this, when calling the global instance of moment, we need to add an additional global.moment check to ensure it actually exists.

coveralls commented 6 years ago

Coverage Status

Coverage remained the same at 93.243% when pulling de11fa08ed774d88a4cb3c37687b7f51ff45d59b on schester44:fix/global-assumption into 25aef52e1448c7d49791bc5133b7adc3cb84926b on urish:master.

urish commented 6 years ago

Thanks!

schester44 commented 6 years ago

@urish Can you publish a new version to npm with this change included?

urish commented 6 years ago

Done!

prakriti-netlight commented 6 years ago

This is broken. I am getting this error now "Cannot set property 'moment' of undefined" . Please fix. Thank you.

schester44 commented 6 years ago

@prakriti-netlight have you checked to see if window.moment or global.moment exists?