Skip to content

Instantly share code, notes, and snippets.

@lyuehh
Created March 12, 2013 09:53
Show Gist options
  • Save lyuehh/5141648 to your computer and use it in GitHub Desktop.
Save lyuehh/5141648 to your computer and use it in GitHub Desktop.
'use strict';
angular.module('angularApp')
.controller('TodoCtrl', function ($scope) {
$scope.todoLists = [
{done: false, value: 'todo1'},
{done: false, value: 'todo2'},
{done: false, value: 'todo3'},
{done: true, value: 'todo4'}
];
$scope.add = function(t) {
this.todoLists.push({
done:false,
value: t.value
});
$scope.t.value = '';
};
$scope.remaining = function() {
return this.todoLists.length - this.todoLists.filter(function(t) {
return t.done;
}).length;
};
$scope.clear = function() {
var reset = this.todoLists.filter(function(t) {
return !t.done;
});
this.todoLists = reset;
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment