Sha256: cff5305dfb2d8cea4f1cfa6aaeb810150b94a440c8c9e460153ce91f07f1f8b1

Contents?: true

Size: 817 Bytes

Versions: 1

Compression:

Stored size: 817 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.saveTodo = (todo) ->
      todo.save()

    $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

1 entries across 1 versions & 1 rubygems

Version Path
todo_rails-0.1.3 app/assets/javascripts/todo_rails/controllers/todoCtrl.coffee