-
Notifications
You must be signed in to change notification settings - Fork 0
/
todo.js
56 lines (30 loc) · 954 Bytes
/
todo.js
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
function TodoCtrl($scope) {
$scope.todos = [
{text:'learn angular', done:true},
{text:'build an angular app', done:false}];
$scope.addTodo = function() {
Kinvey.DataStore.save('Todos', {text:$scope.todoText, done:false}, {
success: function (todo) {
$scope.todos.push(todo);
}
});
$scope.todoText = '';
};
$scope.remaining = function() {
var count = 0;
angular.forEach($scope.todos, function(todo) {
count += todo.done ? 0 : 1;
});
return count;
};
$scope.archive = function() {
var oldTodos = $scope.todos;
$scope.todos = [];
angular.forEach(oldTodos, function(todo) {
if (!todo.done) $scope.todos.push(todo);
});
};
}
//_this.scope.$apply(function() {
// return _this.scope['customerList'] = _this.prepareDataToList(list);
//})