If I have a CoffeeScript class defined in a separate file, which I'm calling from my main script, I can make the functions within the file globally visible, but not the class.
The included file is:
root = exports ? this
root.add = (a, b) ->
return a + b
class root.userModel
username: 'Aaaa'
name: 'Bbbb'
I can access the function from my main code. How can I create the class?
Your code will indeed make userModel
a global, assuming that exports
is undefined and this
is window
. If you're having problems, check those conditions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With