Commit 0fc68319 authored by Pascal Hartig's avatar Pascal Hartig

AngularJS-Perf: Applied trim patch

parent dabdef2b
...@@ -30,12 +30,13 @@ todomvc.controller('TodoCtrl', function TodoCtrl($scope, $location, todoStorage, ...@@ -30,12 +30,13 @@ todomvc.controller('TodoCtrl', function TodoCtrl($scope, $location, todoStorage,
}); });
$scope.addTodo = function () { $scope.addTodo = function () {
if ($scope.newTodo.length === 0) { var newTodo = $scope.newTodo.trim();
if (newTodo.length === 0) {
return; return;
} }
todos.push({ todos.push({
title: $scope.newTodo, title: newTodo,
completed: false completed: false
}); });
todoStorage.put(todos); todoStorage.put(todos);
...@@ -50,6 +51,7 @@ todomvc.controller('TodoCtrl', function TodoCtrl($scope, $location, todoStorage, ...@@ -50,6 +51,7 @@ todomvc.controller('TodoCtrl', function TodoCtrl($scope, $location, todoStorage,
$scope.doneEditing = function (todo) { $scope.doneEditing = function (todo) {
$scope.editedTodo = null; $scope.editedTodo = null;
todo.title = todo.title.trim();
if (!todo.title) { if (!todo.title) {
$scope.removeTodo(todo); $scope.removeTodo(todo);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment