velua velua - 1 year ago 94
AngularJS Question

Cannot read property 'finally' of undefined

I can't figure out why I'm getting an

Cannot read property 'finally' of undefined error here..

$scope.saveToDos = function(){
console.log("Save to do was pressed.")
var filteredTodos = $scope.todos.filter(function(todo){
return todo
console.log("There are " + filteredTodos.length + " edited todos")

It errors out on the finally line and I'm not sure why.
The issue can be reproduced cloning Git repo

this.saveToDos = function(todos){
var queue = [];
var request;
request = $'/api/todos', todo);
} else{
request = $http.put('/api/todos/' + todo._id, todo).then(function(result){
todo =;
return todo
console.log("I saved " + todos.length + " todos!");


Answer Source

You aren't returning anything from saveToDos(), so the return value is by default undefined.

You probably wanted to return $q.all(...

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download