Skip to content

Instantly share code, notes, and snippets.

@ox
Created December 11, 2013 06:11
Show Gist options
  • Save ox/7905785 to your computer and use it in GitHub Desktop.
Save ox/7905785 to your computer and use it in GitHub Desktop.
Basic ToDo app in Angular. this is awful code
<!doctype html>
<html ng-app="todo">
<head>
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css">
</head>
<body>
<div class="container" ng-controller="TodoController as todoctrl">
<div class="row">
<h1>Todos</h1>
</div>
<div class="row" ng-repeat="task in todoctrl.tasks">
<div class="col-lg-4">
<div class="input-group">
<span class="input-group-addon">
<input type="checkbox" ng-model="task.done">
</span>
<input type="text" class="form-control " ng-model="task.message">
</div>
</div>
</div>
<div class="row">
<button class="btn" ng-click="todoctrl.addTodo()">Add Task</button>
</div>
</div>
<script src="http://code.angularjs.org/1.2.4/angular.min.js"></script>
<script src="todoctrl.js"></script>
</body>
</html>
angular.module('todo', [])
.controller('TodoController', function ($scope) {
this.tasks = [
{message: "one", done: true},
{message: "two", done: false}
]
this.addTodo = function addTodo() {
if (this.tasks[this.tasks.length-1].message != "") {
this.tasks.push({message: "", done: false})
}
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment