Skip to content

Instantly share code, notes, and snippets.

@aaizemberg
Created August 8, 2014 19:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aaizemberg/7e286f69a9bb78e19fd2 to your computer and use it in GitHub Desktop.
Save aaizemberg/7e286f69a9bb78e19fd2 to your computer and use it in GitHub Desktop.
todo list en angularjs (con Gaba)
<!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