diff --git a/todo-src/index.html b/todo-src/index.html index 89203ad..6cd7c23 100644 --- a/todo-src/index.html +++ b/todo-src/index.html @@ -7,13 +7,20 @@ + + + - -

My little to do app!

- + + + +

My little to do app! +

+ +
- +
@@ -23,22 +30,38 @@

My little to do app!

- +

stuff i gotta do asap

- + + + +
- + diff --git a/todo-src/script.js b/todo-src/script.js index fe21743..941d878 100644 --- a/todo-src/script.js +++ b/todo-src/script.js @@ -3,24 +3,58 @@ var myApp = angular.module('app', []); myApp.controller('MainCtrl', function ($scope){ - $scope.todos = ["Learn Angular", "Learn node"]; + $scope.todos = [ + { task: "Learn Angular", + value: false + }, + { + task: "Learn node", + value: false + }]; + $scope.newItem = ""; - + +======= + $scope.totalNumber = 2; + $scope.addItem = function(){ console.log("in add"); if ($scope.newItem !== ""){ - $scope.todos.push($scope.newItem); + $scope.todos.push({task: $scope.newItem, value: false}); $scope.newItem = ""; + $scope.totalNumber ++; + document.getElementById('numberOfItems').innerHTML = $scope.totalNumber; } } - + $scope.deleteItem = function(item){ console.log("in delete"); var index = $scope.todos.indexOf(item); $scope.todos.splice(index, 1); + $scope.totalNumber --; + document.getElementById('numberOfItems').innerHTML = $scope.totalNumber; } + $scope.deleteAllCompletedItems = function(){ + for (var i = 0; i < $scope.todos.length; i++) + { + console.log($scope.todos[i].value); + + if ($scope.todos[i].value == true) + { + $scope.todos.splice(i, 1); + } + + } + + } + +//creates a dynamically updating number of tasks + window.onload = function() { + document.getElementById('numberOfItems').innerHTML = $scope.totalNumber; + }; + }); /************************* @@ -32,5 +66,5 @@ myApp.controller('MainCtrl', function ($scope){ * - make it prettier * - add a due date * - add reminder (setInterval) - * - * *********************/ \ No newline at end of file + * + * *********************/