Created
August 8, 2014 19:28
-
-
Save aaizemberg/7e286f69a9bb78e19fd2 to your computer and use it in GitHub Desktop.
todo list en angularjs (con Gaba)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment