Commit 69099778 authored by Stephen Sawchuk's avatar Stephen Sawchuk

angular: api: insert todo after confirming success

parent ec1ff69c
......@@ -75,11 +75,10 @@ angular.module('todomvc')
insert: function (todo) {
var originalTodos = store.todos.slice(0);
store.todos.push(todo);
return $http.post('/api/todos', todo)
.then(function success(resp) {
todo.id = resp.data.id;
store.todos.push(todo);
return store.todos;
}, function error() {
angular.copy(originalTodos, store.todos);
......
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