-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAngular.js
61 lines (57 loc) · 1.8 KB
/
Angular.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
57
58
59
60
61
var mytodoApp=angular.module('mytodoApp',[]);
mytodoApp.controller('mytodoController',['$scope',function($scope){
$scope.appTitle = "Umesh's Awesome ToDo App";
$scope.appHeadline = "Let's start save";
$scope.todos = [];
$scope.addTo=function(){
$scope.todos.push({
text:$scope.todoText,
done:false
});
$scope.todoText = '';
localStorage.setItem('todos', JSON.stringify($scope.todos));
};
$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);
}
});
localStorage.setItem('todos', JSON.stringify($scope.todos));
};
$scope.deleteTask=function(index){
$scope.todos.splice(index,1);
}
$scope.completedTask=function(){
var oldTodos=$scope.todos;
$scope.completetodo=[];
angular.forEach(oldTodos,function(todo){
if(todo.done){
$scope.completetodo.push(todo);
}
});
var myEi=angular.element(document.querySelector(".unstyled"));
myEi.addClass("hide-todo").removeClass("show-todo");
var myEu=angular.element(document.querySelector(".completetodo"));
myEu.addClass("show-todo").removeClass("hide-todo");
var myEn=angular.element(document.querySelector(".todo-form"));
myEn.addClass("hide-todo").removeClass("show-todo");
}
$scope.allTask=function(){
var myEi=angular.element(document.querySelector(".unstyled"));
myEi.addClass("show-todo").removeClass("hide-todo");
var myEu=angular.element(document.querySelector(".completetodo"));
myEu.addClass("hide-todo").removeClass("show-todo");
var myEn=angular.element(document.querySelector(".todo-form"));
myEn.addClass("show-todo").removeClass("hide-todo");
}
}]);