Question

I have included moment.min.js in my page

<script src="js/jquery.js"></script>
<script src="js/modernizr.js"></script>
<script src="js/moment.min.js"></script>
<script src="js/fatcalc.js"></script>

I can call

<script>document.write(moment());</script>

and it displays the date fine on my page.

But, when I call it from within fatcalc.js

var date = moment();

I get the error:

'moment' is not defined.

Why can my html page see it, but not the fatcalc.js file?

Était-ce utile?

La solution

Well, I figured it out. Seems to be some issue with Jshint I don't understand but adding this to the top of my script fixed it.

/*global moment:true */
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top