-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
49 lines (42 loc) · 1.15 KB
/
script.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
var app=angular.module('todo',[]);
app.controller('todoApp',function($scope){
$scope.tasks=[];
var taskdata = localStorage['taskList'];
if(taskdata!==undefined)
{
$scope.tasks=JSON.parse(taskdata);
}
$scope.searchEnter=function(){
if(event.which==13 && $scope.task!="")
{
$scope.addTask();
}
};
$scope.addTask=function()
{
$scope.tasks.push({'taskMessage':$scope.task, 'status':false});
console.log($scope.tasks);
$scope.task="";
localStorage['taskList']=JSON.stringify($scope.tasks);
console.log(localStorage);
};
$scope.contentEdit=function(msg){
for(var i=0;i<$scope.tasks.length;i++)
{
if($scope.tasks[i].taskMessage==msg)
{
$scope.tasks[i].taskMessage=event.target.innerText;
}
}
console.log($scope.tasks);
localStorage['taskList']=JSON.stringify($scope.tasks);
event.target.contentEditable=event.target.contentEditable=='false'?'true':'false';
};
$scope.enterAgain=function(msg)
{
if(event.which==13 && msg!="")
{
$scope.contentEdit(msg);
}
};
});