私はangular jsでrailscasts#405をフォローしていましたが、彼が使用するコードは次のとおりです
app = angular.module("Raffler", ["ngResource"])
app.factory "Entry", ["$resource", ($resource) ->
$resource("/entries/:id", {id: "@id"}, {update: {method: "PUT"}})
]
@RaffleCtrl = ["$scope", "Entry", ($scope, Entry) ->
$scope.entries = Entry.query()
$scope.addEntry = ->
entry = Entry.save($scope.newEntry)
$scope.entries.push(entry)
$scope.newEntry = {}
$scope.drawWinner = ->
pool = []
angular.forEach $scope.entries, (entry) ->
pool.push(entry) if !entry.winner
if pool.length > 0
entry = pool[Math.floor(Math.random()*pool.length)]
entry.winner = true
entry.$update()
$scope.lastWinner = entry
]
実質的に同じコードを使用してアプリケーションに非常によく似たものを実装しようとしましたが、唯一の問題は、drawWinner 関数が呼び出されたときにブラウザーが「変数エントリが見つかりません」というエラーをログに記録することですが、変数エントリは関数 addEntry で宣言されていますか?