Ngx Hellojs
This module is used for Angular 5.
This module help you to use hellojs library as service.
How to use:
Installation:
npm install ngx-hellojs
Import library:
Edit .angular-cli.json
{ //... "apps": [ { //... "scripts": [ //... "../node_modules/hellojs/dist/hello.all.js" ], //... } ], //...}
Import service:
Edit in src/app/app.module.ts
:
//...; ; ; //same with://hello.init({facebook: '<your-app-id>'}, {scope: 'friends, email'});
And call in component:
constructorprivate _ngxHellojsService: NgxHellojsService
Login
<!-- Using directive -->Login facebook
this._ngxHellojsService .login'facebook', .subscribe, ; //same with://hello('facebook').login({scope: 'friends, photos, publish'})// .then(function(data) {}, function(error) {});
Logout
<!-- Using directive -->Logout
this._ngxHellojsService.logout'facebook' .subscribe, ; //same with://hello('facebook').logout()// .then(function(data) {}, function(error) {});
Get auth response
; //same with://var fbResult = hello('facebook').getAuthResponse();
Call api
this._ngxHellojsService.api'facebook', 'me' .subscribe, ; //same with://hello('facebook').api('me')// .then(function(data) {}, function(error) {});
this._ngxHellojsService.api'facebook', 'me/friends', null, .subscribe, ; //same with://hello('facebook').api('me/friends', {limit: 1})// .then(function(data) {}, function(error) {});
On / Off
messageAfterLogin = this._ngxHellojsService.on'auth.login', this.messageAfterLogin;this._ngxHellojsService.off'auth.login', this.messageAfterLogin; //same with://var messageAfterLogin = function () {// console.log('Login successfully');//};////hello.on('auth.login', messageAfterLogin);//hello.off('auth.login', messageAfterLogin);