So I have two controllers, hotels
and videos
. I want the hotels.js.coffee
to be able to access functions created in videos.js.coffee
but I get a "is not defined" error.
I'm new to CoffeeScript so any clues would be appreciated.
CoffeeScript will compile your coffee to JS wrapped in a self-executing function with the scope of the window (function{}).call(this);
So in videos.js.coffee you can write something like:
@getVideo: (id) ->
and the getVideo function will be bound to the window object.
CoffeScript runs inside an anonymous function, so declared funcitons in the same file, aren't exported as global functions.
Try something like this to declare global functions:
window.myFunction = ->
//some code
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