Inject facebook api into Angularjs controller

Asked

Viewed 110 times

0

This function is called by a ng-click on a button in my view, but is not returning anything on the console.

Can someone help me?

$scope.shareContent = function(){
    window.fbAsyncInit  = function(){
        FB.init({
            appID   : '1565222510432359',
            status  : true,
            xfbml   : true,
            version : 'v2.3'
        });

        var obj  = {
            method  : 'feed',
            name    : 'Teste',
            link    : 'https://developers.facebook.com/docs/',
            caption : 'teste exemplo'
        }

        FB.ui(obj,function(response){}); 
    };
}
  • Did you set something to be written on the console at some point? I don’t see anything in your code.. Try this.: FB.ui(obj,function(response){ console.log(response) });

  • That one FB.ui, was to open a share box and opened nothing. What I’m trying to do is open a share box

  • So your different question, because you wondered why there was nothing on the console. Are you using some angular plugin to integrate facebook? Or are you trying to raw use their api?

  • I’m trying normally, no plugin. My question of not appearing something on the console, was that pro yes or no, should appear some error or something like.

  • not necessarily, because you didn’t make it explicit, what it would provide of error is if something came into conflict with the angular in general, like an injection error, for example. But about fb, I recommend you to work with some existing plugin, because they make the flow A lot easier and make your code easier to manage, see this for example: https://github.com/Ciul/angular-facebook

  • i came to see this plugin, it is very pro that I have to do, I just want to load the sdk from facebook and show a share box with dynamic content.

  • I don’t know how to help you, I confess that I never did so, but according to Facebook itself, I think you will need to change the way you are working, see: https://developers.facebook.com/docs/javascript/howto/angularjs

Show 2 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.