block by aaizemberg 7e286f69a9bb78e19fd2

todo list en angularjs (con Gaba)

Full Screen

index.html

<!DOCTYPE html>
<html>

<body ng-app ng-controller="todoCtrl">

<h2>Todo list</h2>

<form ng-submit="todoAdd()">
    <input type="text" ng-model="todoInput" size="50" placeholder="Add New">
    <input type="submit" value="Add New">
</form>

<br>

<div ng-repeat="x in todoList">
  <input ng-change="remove(x)" type="checkbox" ng-model="x.done"><span ng-bind="x.todoText"></span>
</div>


<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular.min.js"></script>

<script>
    function todoCtrl($scope) {
    $scope.todoList = [{todoText:'tutorial de AngularJS', done:false}, {todoText:'pintar la casa', done:false}];

    $scope.todoAdd = function() {
        if ($scope.todoInput !== "") {
          $scope.todoList.push({todoText:$scope.todoInput, done:false});
        } 
        $scope.todoInput = "";
    };
    $scope.remove = function(item) {
  $scope.todoList.splice($scope.todoList.indexOf(item),1);
       
    };
}
</script>
  
</body>
</html>