Skip to content
This repository has been archived by the owner. It is now read-only.
Branch: master
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
79 lines (77 sloc) 2.38 KB
<html ng-app="toDoApp">
<script src=""></script>
<script src=""></script>
<script src=""></script>
<link href="" rel="stylesheet">
<!-- you need <script></script> complete tag, otherwise html doesn't like it -->
<body ng-controller="TODOCtrl">
<div class="container">
<h3 class="lead">My to-do list</h3>
<ul class="table table-bordered table-striped">
<li ng-repeat="item in list">
<span ng-bind="item.desc" class="done-{{item.done}}"></span>
<!-- <input type="button" value="-" ng-click="removeItem($index)" class="todo-destroy"></input> -->
<span class="todo-destroy"><i class="icon-remove icon-large" ng-click="removeItem($index)"></i></span>
<input type="checkbox" ng-model="item.done" class="word-done">
<span ng-bind="item.time | fromNow" class="time"></span>
<input type="textfield" ng-model="newItem"></input>
<input type="button" value="Add" ng-click="addItem()"></input>
<input type="text" ng-model="newItem" add-on-enter="addItem(newItem)" />
var toDoAppModule = angular.module("toDoApp", []);
toDoAppModule.directive("addOnEnter", function () {
return {
restrict: 'A',
link: function (scope, element, attrs) {
// console.log(attrs);
element.bind('keypress', function (event) {
if (event.charCode === 13) {
toDoAppModule.filter('fromNow', function() {
return function (time) {
return moment(time).fromNow();
TODOCtrl = function($scope){
$scope.list = [{
desc: "First thing to do!",
done: false,
time: new Date(Math.random())
$scope.addItem = function(){
desc: $scope.newItem,
time: new Date()
$scope.newItem = "";
$scope.removeItem = function(index){
$scope.list.splice(index, 1);
<style >
.done-true {
text-decoration: line-through;
color: grey;
color: grey;
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.