Skip to content

Instantly share code, notes, and snippets.

@Showtimes
Created March 5, 2013 22:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Showtimes/5095113 to your computer and use it in GitHub Desktop.
Save Showtimes/5095113 to your computer and use it in GitHub Desktop.
$scope.addEntry = ->
$scope.entries.push($scope.newEntry)
$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
$scope.lastWinner = entry
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment