I'm using Coffeescript and am trying to define a controller which will use the "HomeController as homeCtrl" syntax.
angular.module('myApp.controllers',[]).controller("HomeController", ->
@someArray = []
# return
)
This is broken - the scope.homeCtrl
is set as []
rather than the object {someArray: []}
. I realize this is because Coffeescript automatically returns the last line of a function, so the transpiled return this.someArray = []
returns []
for the function. I can fix this by uncommenting the bare return
command, or even something like return true
or @baz='foobar'
. But the really weird part is that this only messes up when the last line of the function returns an array. What's going on?