Sha256: f95b2f5ec22956111b8add051a1e892cc2c69b9cb482e697c74f187f76d3c6b2

Contents?: true

Size: 800 Bytes

Versions: 2

Compression:

Stored size: 800 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 =

        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

2 entries across 2 versions & 1 rubygems

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