Last active
March 27, 2017 17:22
-
-
Save itswadesh/29c1737c76e8657752e4b4e9eb50839c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Define an angular module for our app | |
var app = angular.module('myApp', []); | |
app.controller('tasksController', function($scope, $http) { | |
getTask(); // Load all available tasks | |
function getTask(){ | |
$http.post("ajax/getTask.php").success(function(data){ | |
$scope.tasks = data; | |
}); | |
}; | |
$scope.addTask = function (task) { | |
$http.post("ajax/addTask.php?task="+task).success(function(data){ | |
getTask(); | |
$scope.taskInput = ""; | |
}); | |
}; | |
$scope.deleteTask = function (task) { | |
if(confirm("Are you sure to delete this line?")){ | |
$http.post("ajax/deleteTask.php?taskID="+task).success(function(data){ | |
getTask(); | |
}); | |
} | |
}; | |
$scope.toggleStatus = function(item, status, task) { | |
if(status=='2'){status='0';}else{status='2';} | |
$http.post("ajax/updateTask.php?taskID="+item+"&status="+status).success(function(data){ | |
getTask(); | |
}); | |
}; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment