diff --git a/todo-src/index.html b/todo-src/index.html index 475819d..3c495ec 100644 --- a/todo-src/index.html +++ b/todo-src/index.html @@ -7,15 +7,24 @@ + + + + -

My little to do app!

- + +

My little to do app! +

+ + + +
- +
- +
- +

stuff i gotta do asap

- +
- + + + + + diff --git a/todo-src/script.js b/todo-src/script.js index fe21743..251e925 100644 --- a/todo-src/script.js +++ b/todo-src/script.js @@ -3,9 +3,17 @@ var myApp = angular.module('app', []); myApp.controller('MainCtrl', function ($scope){ - $scope.todos = ["Learn Angular", "Learn node"]; + $scope.todos = [ + {name: "Learn Angular", editing:false}, + {name: "Learn node", editing: false} + ]; $scope.newItem = ""; - + + + + $scope.totalNumber = 2; + + $scope.addItem = function(){ console.log("in add"); if ($scope.newItem !== ""){ @@ -13,14 +21,38 @@ myApp.controller('MainCtrl', function ($scope){ $scope.newItem = ""; } } - + $scope.deleteItem = function(item){ console.log("in delete"); var index = $scope.todos.indexOf(item); $scope.todos.splice(index, 1); } - + +// Edit function +$scope.editItem = function (item) { + item.editing = true; + item.oldName = item.name; + } + + $scope.doneEditing = function (item) { + item.editing = false; + //dong some background ajax calling for persistence... + }; + $scope.Cancel = function (item) { + item.editing = false; + item.name = item.oldName; + }; + + //End of Edit functions + + +//creates a dynamically updating number of tasks + window.onload = function() { + document.getElementById('numberOfItems').innerHTML = $scope.totalNumber; + }; + + }); /************************* @@ -32,5 +64,5 @@ myApp.controller('MainCtrl', function ($scope){ * - make it prettier * - add a due date * - add reminder (setInterval) - * - * *********************/ \ No newline at end of file + * + * *********************/