todoService , . , todoService $firebase, todos, . , .
, , :
TodoCtrl
, TodoCtrl, ng-repeat. ng-repeat .
Ng-repeat .
. , . , ng-repeat = "todo in todos", todo .
, ng-repeat todo.
$scope.todos.[$todo].done, $scope.todos. $scope.todos .
$scope.todos
$bind, $scope.todos $scope.todos.todo.done. , , . , , , , :
todoService.$bind($scope, 'todos');
todos, $save $bind:
$scope.todos = todoService;
<input type="checkbox" ng-model="todo.done" ng-change="$parent.todos.$save(id)">
:
angular.module('singularPracticeApp')
.service('todoService', function($firebase) {
return $firebase( new Firebase(URL_TO_TODOS_LIST) );
});
.controller('TodoCtrl', function($scope, todoService) {
todoService.$bind($scope, 'todos');
$scope.addTodo = function () {
$scope.todos.$add({text: $scope.todoText, done:false});
$scope.todoText = '';
};
});