baniol
6/11/2013 - 10:45 AM

angular module coffeescript

angular module coffeescript

# Original source at: http://angularjs.org/#todo-js

angular.module('TodoApp').controller '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
// Make our app module, its easier to do this in raw javascript
// and then put the rest of our app content (controllers etc)
// in their own coffeescript files.
//
// Your ng-app should include this module name, eg: <html ng-app="TodoApp">
angular.module('TodoApp', []);