Hi Roe...,
> Whatever i try, everything inside a function works correct inside the
> controller but outside this function i still end up with the stupid Object
> instead of a json array.
>
Euhm, yes, that is how async programming works..
var myTest= jamboFactory.query(function(data){
//this code runs AFTER the controller function is done, and after the
async request has ended.
console.log(data.thedata); // output: JSON ARRAY! // yep, it works.. :)
scope.result = data.theData; // once you hook your data to the scope,
you can use it in your view!
return data.thedata; //this return will fire in the future, and
basically does nothing for you!
});
console.log('myTest here is:'+myTest); // freaking Object. //That is
correct as this code runs BEFORE the query callback, it holds a reference
to the promise the jamboFactory.query() produces
I hope this helps you a bit,
Regards
Sander
--
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 https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.