-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathapp.component.ts
More file actions
36 lines (33 loc) · 848 Bytes
/
app.component.ts
File metadata and controls
36 lines (33 loc) · 848 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import { Component, OnInit, NgZone} from 'angular2/core';
import {FacebookService} from './facebook.service';
@Component({
selector: 'my-app',
templateUrl: 'app/facebook.component.html',
providers: [FacebookService]
})
export class AppComponent implements OnInit{
name=""
isUser = false
constructor(
private _ngZone: NgZone
private _facebookService: FacebookService
){}
ngOnInit(){
this._facebookService.loadAndInitFBSDK();
}
login(){
var self = this;
FB.login(function(response) {
if (response.authResponse) {
FB.api('/me', function(response) {
self._ngZone.run(() => {
self.name = response.name;
self.isUser = true
});
});
}else{
console.log('User cancelled login or did not fully authorize.');
}
});
}
}