javascript - AngularJS - Asynchronous call to Facebook API -


i'am trying call facebook api angularjs.

the problem calls fb api asynchronous, need know when query on facebook avaliable use in agularjs.

for this, call method in controller:

facebook.getloginstatus();

which facebook service, defined as:

app.factory('facebook', function() {

    getloginstatus: function() {          fb.getloginstatus(function(stsresp) {             console.log(stsresp);             if(stsresp.authresponse) {                 // user logged in                 return true;             } else {                 // user not logged in.                 return false;             }         });     } 

}

what want in case check if user logged. if true, i'll show options, otherwise, i'll show login button.

i've try use $q.defer() functions, promises, factorys watch response data, everything. works want. i've checked development examples based on egghead.io examples, think i'm not understand asynchronous calls in angularjs.

thanks in advance.

here's full basic working example of wrapping facebook api in angular service:

http://plnkr.co/edit/0grldwpjozgfy14irxlt?p=preview

see answer question (which has partial examples of angular-fb integration):

angularjs : use promises?


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -