Created
December 11, 2013 06:11
-
-
Save ox/7905785 to your computer and use it in GitHub Desktop.
Basic ToDo app in Angular. this is awful code
This file contains hidden or 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 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> |
This file contains hidden or 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
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