Sha256: 2cd480ff2998f9704d90ec06a6f2bdd36517aedbe1f9a91cef0b7c082dfd8e60

Contents?: true

Size: 766 Bytes

Versions: 3

Compression:

Stored size: 766 Bytes

Contents

# angular.module('todoRails.controllers').controller 'todoCtrl', ($scope, $log, Restangular) ->
#   $scope.todos = Restangular.all('tasks').getList().$object
#   $log.log $scope.todos


angular.module('todoRails.controllers').controller 'todoCtrl', [
  '$scope', 'Restangular'
  ($scope, Restangular) ->
    todos = Restangular.all('tasks')

    $scope.reload = ->
      $scope.todos = todos.getList().$object

    $scope.reload()

    $scope.addTodo = ->
      todo =
        task:
          title: $scope.todoText
          completed: false
      todos.post todo
      $scope.todoText = ''
      $scope.reload()

    $scope.remaining = ->
      count = 0
      angular.forEach $scope.todos, (todo) ->
        count += if todo.completed then 0 else 1
      count
]

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
todo_rails-0.1.2 app/assets/javascripts/todo_rails/controllers/todoCtrl.coffee
todo_rails-0.1.1 app/assets/javascripts/todo_rails/controllers/todoCtrl.coffee
todo_rails-0.1.0 app/assets/javascripts/todo_rails/controllers/todoCtrl.coffee