Skip to content

Commit

Permalink
AngularJS+Require: Applied trim patch
Browse files Browse the repository at this point in the history
  • Loading branch information
passy committed May 24, 2013
1 parent a9abf95 commit dabdef2
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ define(['app', 'services/todoStorage'], function (app) {
$scope.editedTodo = null;

$scope.$watch('todos', function () {
$scope.remainingCount = filterFilter(todos, {completed: false}).length;
$scope.remainingCount = filterFilter(todos, { completed: false }).length;
$scope.doneCount = todos.length - $scope.remainingCount;
$scope.allChecked = !$scope.remainingCount;
todoStorage.put(todos);
Expand All @@ -36,12 +36,13 @@ define(['app', 'services/todoStorage'], function (app) {


$scope.addTodo = function () {
if (!$scope.newTodo.length) {
var newTodo = $scope.newTodo.trim();
if (!newTodo.length) {
return;
}

todos.push({
title: $scope.newTodo,
title: newTodo,
completed: false
});

Expand All @@ -56,6 +57,8 @@ define(['app', 'services/todoStorage'], function (app) {

$scope.doneEditing = function (todo) {
$scope.editedTodo = null;
todo.title = todo.title.trim();

if (!todo.title) {
$scope.removeTodo(todo);
}
Expand Down

0 comments on commit dabdef2

Please sign in to comment.