I've recently encountered an issue while using AngularJS and NGResource. For some reason, every time I try to use the query function, I receive an empty array in return.
Within my controller, the code looks like this:
Task = $resource('/tasks');
var tasks = Task.query(function () {});
console.log(tasks);
$scope.tasks = tasks;
When I display {{tasks}} in the view, it appears correctly as below:
[{"created_at":"08/08/2013","created_by_id":2,"description":"description","id":1,"name":"test task 1","parent_task_id":null,"task_type_id":1,"updated_at":"08/08/2013"},
{"created_at":"08/08/2013","created_by_id":2,"description":"description","id":2,"name":"test task 2","task_type_id":1,"updated_at":"08/08/2013"}]
However, in the console, it shows an empty array:
[]
Furthermore, when using the batarang extension for Chrome, the scope displayed for tasks is:
tests:
[ ]
Before assigning the returned value to the $scope model, I need to perform some data operations on it. Is this behavior normal or am I missing something? Any insights would be greatly appreciated as I have spent quite a bit of time trying to resolve this issue.