Having an issue while using Coffeescript to define a controller with the "HomeController as homeCtrl" syntax.
angular.module('myApp.controllers',[]).controller("HomeController", ->
@someArray = []
# return
)
Encountering a problem where scope.homeCtrl
is being set as []
instead of the expected object {someArray: []}
. The root cause seems to be that Coffeescript automatically returns the last line of a function, resulting in return this.someArray = []
returning []
for the function. One workaround is to uncomment the bare return
command, or use something like return true
or @baz='foobar'
. Oddly enough, this issue only occurs when the last line of the function returns an array. What could be causing this?