Reputation: 65
I tried using Facebook API for logging users in to my Angular-2 application . I am getting an error in my typescript file . 'Cannot find name FB'.
(<any>window).fbAsyncInit = function() {
FB.init({
appId : '123456789012345',
cookie : true,
xfbml : true,
version : 'v2.8'
});
FB.getLoginStatus(function(response) {
statusChangeCallback(response);
});
};
Can anybody provide a solution to this? Thanks in advance!!
Upvotes: 1
Views: 1514
Reputation: 221
You need to declare a constant to use facebook SDK with angular.
Declare FB constant right above component declaration.
declare var FB: any;
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: []
})
Then initialise facebook SDK inside your constructor function.
Upvotes: 3