AngularJS Todo sample controller converted to CoffeeScript
https://gist.github.com/2951973
todo.coffee
# Original source at: http://angularjs.org/#todo-js
window.TodoCtrl = ($scope) ->
$scope.todos = [
{text: 'learn angular', done: true},
{text: 'build an angular app', done: false}
]
$scope.addTodo = ->
$scope.todos.push({text: $scope.todoText, done: false})
$scope.todoText = ''
$scope.remaining = ->
count = 0
for todo in $scope.todos
count += todo.done ? 0: 1
count
$scope.archive = ->
oldTodos = $scope.todos
$scope.todos = []
for todo in oldTodos
$scope.todos.push(todo) unless todo.done
Written by Edward J. Stembler
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Coffeescript
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#