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
2 changes: 1 addition & 1 deletion 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="enterKey($event)">
<span class="input-group-btn">
<button class="btn btn-default" type="button" ng-click="addItem()">
Add
Expand Down
16 changes: 11 additions & 5 deletions todo-src/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,24 @@ myApp.controller('MainCtrl', function ($scope){
$scope.newItem = "";

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

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

$scope.enterKey = function(event) {
if (event.keyCode == 13) {
$scope.addItem();
}
}


});
Expand Down
2 changes: 1 addition & 1 deletion todo-src/style.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Styles go here */
body {
background: green;
background: #5999C8;
}