-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
34 lines (30 loc) · 817 Bytes
/
Copy pathmain.js
File metadata and controls
34 lines (30 loc) · 817 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
angular.module('todoApp', [])
.controller('todoController', function () {
var self = this;
self.todoList = [
{ text: 'Learn HTML5', isDone: false },
{ text: 'Learn JavaScript', isDone: false },
{ text: 'Learn AngularJs', isDone: false }
];
self.addTodo = function () {
if(!self.todoText ||self.todoText == '') return;
self.todoList.push({ text: self.todoText, isDone: false });
self.todoText = "";
};
self.remaining = function () {
var count = 0;
angular.forEach(self.todoList, function (todo) {
count += todo.isDone ? 1 : 0;
});
return count;
};
self.archive = function () {
var oldTodoList = self.todoList;
self.todoList = [];
angular.forEach(oldTodoList, function (todo) {
if (!todo.isDone) {
self.todoList.push(todo);
}
});
};
});