46de8790
Tarpit Grover
first commit
|
1
2
3
4
5
6
7
8
9
10
11
|
(function() {
var app = angular.module('todoapp', []);
app.controller('TodoCtrl', ['$scope', '$http', function($scope, $http) {
//console.log("Hello World from controller");
$http.get('/todolist').success(function(response) {
//console.log("I got the data I requested");
$scope.todolist = response;
});
$scope.task = {
|
f32b8539
unknown
Improved Code
|
12
|
taskname: "",
|
46de8790
Tarpit Grover
first commit
|
13
|
Done: false,
|
f32b8539
unknown
Improved Code
|
14
15
|
details: ""
}
|
46de8790
Tarpit Grover
first commit
|
16
17
|
$scope.addTask = function() {
//console.log($scope.todo);
|
f32b8539
unknown
Improved Code
|
18
|
|
46de8790
Tarpit Grover
first commit
|
19
|
$http.post('/todolist', $scope.task).success(function(response){
|
f32b8539
unknown
Improved Code
|
20
21
22
23
24
25
26
27
28
29
|
$http.get('/todolist').success(function(response) {
$scope.todolist = response;
});
console.log(response);
$scope.task = {
taskname: "",
Done: false,
details: ""
}
});
|
f32b8539
unknown
Improved Code
|
30
31
32
33
34
35
36
37
38
39
40
41
42
|
};
$scope.updateTask = function(task) {
$http.put('/todolist/'+task._id,task).success(function(response) {
});
};
$scope.deleteTask = function(id) {
var x=confirm("Are you sure?")
if(x==true){
$http.delete('/todolist/' + id).success(function(response) {
|
46de8790
Tarpit Grover
first commit
|
43
44
45
46
47
48
49
|
console.log(response);
});
$http.get('/todolist').success(function(response) {
$scope.todolist = response;
});
$scope.todo = "";
};
|
f32b8539
unknown
Improved Code
|
50
|
}
|
46de8790
Tarpit Grover
first commit
|
51
52
53
54
|
}]);
})();
|