Try:

App.controller('TasksController', function(Task) {
  $scope.tasks = Task.all();
});


On Wednesday, January 22, 2014 7:34:25 AM UTC+2, Stuart Clove wrote:
>
> 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.
>

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to