There is a functions.js file located in src/lib/ and there is a function in it. That file has been included into slug.json.

How could we call that function inside the controller?

有帮助吗?

解决方案

In coffeescript each file is wrapped with an anonymous function to avoid leaking into global scope. If you want to leak into global scope on purpose, you need to put the function in "window":

window.check_pants = (size) ->
  "No pants are too tight"

You can then call the function in the controller as "check_pants", that is to say that callers don't need to include "window".

Since "this" refers to window by default, you can use an "@" sign:

@check_slants = (size) ->
  "Too slanted"
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top