Last active
December 7, 2016 10:23
-
-
Save pankajpatel/e93ef5aff278f05f573e to your computer and use it in GitHub Desktop.
ToDoAppAngularJsCode
This file contains 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
var app = angular.module('toDoApp', []); | |
app | |
.controller('ToDoController', ['$scope', function ($scope) { | |
$scope.tasks = []; | |
$scope.editIndex = false; | |
$scope.addTask = function () { | |
if( $scope.editIndex === false){ | |
$scope.tasks.push({task: $scope.task, done: false}) | |
} else { | |
$scope.tasks[$scope.editIndex].task = $scope.task; | |
} | |
$scope.editIndex = false; | |
$scope.task = ''; | |
} | |
$scope.editTask = function (index) { | |
$scope.task = $scope.tasks[index].task; | |
$scope.editIndex = index; | |
} | |
$scope.doneTask = function (index) { | |
$scope.tasks[index].done = true; | |
} | |
$scope.unDoneTask = function (index) { | |
$scope.tasks[index].done = false; | |
} | |
$scope.deleteTask = function (index) { | |
$scope.tasks.splice(index, 1); | |
} | |
}]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment