I have table for some task, In that table every row has one task. In every row there is status which is controller by one button. Initial status of every task will be show as In Progress and text of Button as Mark Done, But when click on the button then It will change the status of the task as Done and change the text of button as Mark In Progress. If In future If we want to change the status of "Done" task then we can change the status through Button "Mark In Progress". Please see DEMO onDEMO on Plunker
Angularjs
<script>
var app = angular.module('myApp', []);
app.controller('tasksCtrl', function($scope, $http) {
$http.get("data.json")
//$http.get("/todo/api/v1.0/tasks")
.success(function(response) {
$scope.tasks = response.tasks;
});
$scope.markInProgress=function(task){
alert("markInProgress");
title=task.title;
description=task.description;
uri=task.uri;
var data={title: title, description: description, done: false, uri:uri};
// For server But here there is no server so I assigne data outside $http.put
$scope.tasks[$scope.index] = data;
// For server
$http.put(uri, data)
.success(function(){
$scope.tasks[$scope.index] = data;
});
};
$scope.markDone=function(task){
alert("markDone");
title=task.title;
description=task.description;
uri=task.uri;
var data={title: title, description: description, done: true, uri: uri};
// For server But here there is no server so I assigne data outside $http.put
$scope.tasks[$scope.index] = data;
// For server
$http.put(uri, data)
.success(function(){
$scope.tasks[$scope.index] = data;
});
};
});
</script>