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
14 changes: 12 additions & 2 deletions todo-src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ <h1 class="text-center">My little to do app!</h1>
<div id="todo" class="col-xs-6 col-xs-offset-3" ng-controller="MainCtrl">

<div class="input-group">
<input type="text" class="form-control" placeholder="Item to add to todo list" ng-model="newItem">
<input type="text" class="form-control" placeholder="Item to add to todo list" ng-model="newItem" ng-keypress="$event.keyCode == 13 ? addItem() : false">
<span class="input-group-btn">
<button class="btn btn-default" type="button" ng-click="addItem()">
Add
Expand All @@ -28,9 +28,19 @@ <h2>stuff i gotta do asap</h2>

<ul class="list-group">
<!-- http://www.w3schools.com/css/css_float.asp -->
<button class="btn btn-success" type="button" ng-init="count=2">
Total Tasks: {{count}}
</button>
<li class="list-group-item clearfix" ng-repeat="do in todos">

<span>{{do}}</span>
<div ng-hide="editorEnabled">
<span>{{do}}</span>
<a href="#" ng-click="editorEnabled=!editorEnabled">Edit</a>
</div>
<div ng-show="editorEnabled">
<input ng-model="do">
<a href="#" ng-click="editorEnabled=!editorEnabled">Done</a>
</div>
<button class="btn btn-danger pull-right" type="button" ng-click="deleteItem(do)">
<span class="glyphicon glyphicon-trash " aria-hidden="true"></span>
</button>
Expand Down
3 changes: 3 additions & 0 deletions todo-src/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,22 @@ var myApp = angular.module('app', []);
myApp.controller('MainCtrl', function ($scope){
$scope.todos = ["Learn Angular", "Learn node"];
$scope.newItem = "";
$scope.count = 2;

$scope.addItem = function(){
console.log("in add");
if ($scope.newItem !== ""){
$scope.todos.push($scope.newItem);
$scope.newItem = "";
$scope.count+=1;
}
}

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


Expand Down