Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 29 additions & 9 deletions todo-src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,34 +11,54 @@

<body ng-app="app">
<h1 class="text-center">My little to do app!</h1>

<div id="todo" class="col-xs-6 col-xs-offset-3" ng-controller="MainCtrl">

<form>
<div class="input-group">
<input type="text" class="form-control" placeholder="Item to add to todo list" ng-model="newItem">
<span class="input-group-btn">
<button class="btn btn-default" type="button" ng-click="addItem()">
<button class="btn btn-default" type="submit" ng-click="addItem()">
Add
<span class="glyphicon glyphicon-ok" aria-hidden="true"></span>
</button>
</span>
</div><!-- /input-group -->
</form>
<h2>stuff i gotta do asap</h2>

<button id="editorBtn" class="pull-right btn btn-default" type="button" ng-click="toggleEditMode()">{{editmode ? 'Done' : 'Edit Todo List'}}</button>
<br>
<br>
<ul class="list-group">
<!-- http://www.w3schools.com/css/css_float.asp -->
<li class="list-group-item clearfix" ng-repeat="do in todos">

<span>{{do}}</span>
<button class="btn btn-danger pull-right" type="button" ng-click="deleteItem(do)">
<span ng-attr-contenteditable="{{ editmode }}">{{do.text}}</span>
<button class="btn btn-danger pull-right" type="button" ng-click="deleteItem($index)">
<span class="glyphicon glyphicon-trash " aria-hidden="true"></span>
</button>

<!-- Complete Button -->
<button class = "btn btn-success pull-right" type="button" ng-click="completeItem($index)">
<span class="glyphicon glyphicon-check" aria-hidden="true"></span>
</button>
</li>
</ul>

<!-- Completed Items List -->
<h2>
Completed Items
</h2>
<ul class="list-group" id="complete">
<li class="list-group-item clearfix" ng-repeat="el in completeItems">
<span>{{el.text}}</span>
</li>
</ul>
<!-- Clear Completed Items Button -->
<button class="btn btn-danger" type="button" ng-click="clearCompletedItems()">
Clear Completed Items
</button>

</div>

</body>

</html>
49 changes: 39 additions & 10 deletions todo-src/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,53 @@
var myApp = angular.module('app', []);

myApp.controller('MainCtrl', function ($scope){
$scope.todos = ["Learn Angular", "Learn node"];

$scope.todos = [
{
text: "Learn Angular"
},
{
text: "Learn node"
}
];

$scope.completeItems = [];

$scope.newItem = "";

$scope.addItem = function(){
console.log("in add");
if ($scope.newItem !== ""){
$scope.todos.push($scope.newItem);
$scope.todos.push({
text: $scope.newItem,
});
$scope.newItem = "";
}
}

$scope.deleteItem = function(item){
$scope.toggleEditMode = function()
{
console.log("in edit");
$scope.editmode = !($scope.editmode);
}

$scope.deleteItem = function(index){
console.log("in delete");
var index = $scope.todos.indexOf(item);
$scope.todos.splice(index, 1);
}



$scope.completeItem = function(index) {
console.log("in complete");
$scope.completeItems.push({
text: $scope.todos[index].text,
});
$scope.deleteItem(index);
}

$scope.clearCompletedItems = function() {
console.log("in clearCompletedItems");
$scope.completeItems.length = 0;
}

});

/*************************
Expand All @@ -32,5 +61,5 @@ myApp.controller('MainCtrl', function ($scope){
* - make it prettier
* - add a due date
* - add reminder (setInterval)
*
* *********************/
*
* *********************/
6 changes: 6 additions & 0 deletions todo-src/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,9 @@
body {
background: green;
}


/* Styling for complete */
#complete {
text-decoration: line-through;
}