If I have a factory where I want to return all tasks:
App.factory('Task', function(TaskResource) {
return {
all: function() {
TaskResource.query().then(function(results) {
return results;
}
}
};
});
and I try to use it in the "TasksController":
App.controller('TasksController', function('Task') {
$scope.tasks = Task.all();
});
I get the result of 'undefined'. If I log the results in the factory itself, they return correctly. Can someone help me understand why this is happening? Thanks.