Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use fb-login-button directive #81

Open
Kukiwon opened this issue Jan 9, 2018 · 1 comment
Open

How to use fb-login-button directive #81

Kukiwon opened this issue Jan 9, 2018 · 1 comment

Comments

@Kukiwon
Copy link

Kukiwon commented Jan 9, 2018

Thank you for developing this library!
I'm trying to figure out how to use the fb-login-button directive. I want to get notified when the user clicks the login button. I have discovered an onLogin attribute in the directive but when I supply a scope-bound function it tells me it cannot find that method once I click the button.

Here's my button HTML:
<div class="fb-login-button" data-size="large" data-button-type="login_with" data-auto-logout-link="false" data-use-continue-as="true" on-login="loginWithFacebook()"></div>

Once I click the button (I'm already logged in) I get the following:
screen shot 2018-01-09 at 11 44 38

Can you tell me how to use the on-login attribute so that I can do something once the user clicks the button? Thank you!

@pc035860
Copy link
Owner

Hi @Kukiwon, the on-login attribute on the directive is currently called from Facebook JS SDK, which means it's not aware of AngularJS context.

Maybe something like this will work (untested):

angular.module('myApp').run(function ($rootScope) {
  window.myAppRootScropeBroadcast = function (arguments) {
    var args = Array.prototype.slice.call(arguments);
    return $rootScope.$broadcast.apply($rootScope, args);
  };
});
<div class="fb-login-button"
  data-size="large"
  data-button-type="login_with"
  data-auto-logout-link="false"
  data-use-continue-as="true"
  on-login="myAppRootScopeBroadcast('FB login button login')"></div>

Or you should just use FB.Event.subscribe to subscribe to login/logout events.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants