Skip to content

Instantly share code, notes, and snippets.

@itswadesh
Last active March 27, 2017 17:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save itswadesh/29c1737c76e8657752e4b4e9eb50839c to your computer and use it in GitHub Desktop.
Save itswadesh/29c1737c76e8657752e4b4e9eb50839c to your computer and use it in GitHub Desktop.
//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