I'm trying to run the following function
var getjson = function(){
$.get('/api/todos/testing', function(results){
return results;
});
}
The results should look like this:
[{_id: "57803baf0a76d5c924b18ca2", username: "testing", toDoTask: "Buy Water", isDone: false, __v: 0},{_id: "57803baf0a76d5c924b18ca3", username: "testing", toDoTask: "Buy Milk", isDone: false, __v: 0}]
When I try to call the function to append the list to my Angular controller
angular.module('firstapp').controller('todos', function(){
this.list= getjson();
});
The list does not save the values returned by the function.
I'm sure the problem is related to the way I'm trying to return the results but I couldn't find what's the right way to do it.