-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
44 lines (35 loc) · 1.14 KB
/
app.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
var todoApp = angular.module('todoApp', []);
todoApp.directive('taskListView', function() {
return {
restrict: 'AECM',
templateUrl: '/pages/taskList.html',
replace: true,
controller: 'TaskController',
scope: {
tasks: "=",
errorMessage: "@"
}
}
});
todoApp.controller('TaskController', ['$scope', '$http', function($scope, $http) {
// List Tasks
var getTasks = function() {
$http.get('/tasks').then((response) => {
$scope.tasks = response.data;
}, (response) => {
$scope.getErrMsg = "Error status: " + response;
});
}
// Add Task
$scope.addTask = function() {
$http.post('/addtask', {'name' : $scope.task_name, 'description' : $scope.task_description, 'assignee' : $scope.task_assignee, 'status' : $scope.task_status}).then(function(data,
status) {
$scope.task_name = '';
$scope.task_description = '';
$scope.task_assignee = '';
$scope.task_status = '';
getTasks();
})
}
getTasks();
}]);