Never Pummel Muskoxen

    ngx-zalo
    TypeScript icon, indicating that this package has built-in type declarations

    0.0.19 • Public • Published

    Ngx Zalo

    This module is used for Angular 5.
    This module help you to use Zalo SDK as service.

    Demo Ngx Zalo.

    How to use:

    Installation:

    npm install ngx-zalo

    Import service:

    Edit in src/app/app.module.ts:

    //...
    import { NgxZaloModule, NgxZaloService } from 'ngx-zalo';
     
    const zaloConfigs = {
      version: '2.0',
      appId: '<appId>',
      redirectUrl: '<redirectUrl>',
    };
     
    @NgModule({
      //...
      imports: [
        //...
        NgxZaloModule,
      ],
      bootstrap: [AppComponent]
    })
    export class AppModule {
     
      constructor(ngxZaloService: NgxZaloService) {
        ngxZaloService.init(zaloConfigs);
      }
     
    }

    And call in component:

    constructor(private _ngxZaloServiceNgxZaloService) {
    }

    Login

    <!-- Using directive -->
    <p ngxLoginZalo>Login Zalo</p>
    //Using controller
    login() {
      this._ngxZaloService.login();
    }

    Logout

    <!-- Using directive -->
    <p ngxLogoutZalo (successEvent)="logoutSuccessfullyAction()">Logout Zalo</p>
    //Using controller
    logout() {
      this._ngxZaloService.logout().subscribe();
    }

    Update login info - Call this function in redirect page to store zalo info

    constructor(private _routerRouter, private _ngxZaloServiceNgxZaloService) {
      this._ngxZaloService.updateLoginInfo().subscribe(() => {
        this._router.navigate(['/']);
      });
    }

    Check login status

    checkLoginStatus() {
      console.log('Login status:', this._ngxZaloService.isLogin);
    }

    Get my profile

    getMyProfile() {
      this._ngxZaloService.getMyProfile().subscribe(result => {
        console.log('My profile:', result);
      });
    }

    Get access token

    getAccessToken() {
      console.log(this._ngxZaloService.accessToken);
    }

    Install

    npm i ngx-zalo

    DownloadsWeekly Downloads

    0

    Version

    0.0.19

    License

    MIT

    Unpacked Size

    79 kB

    Total Files

    18

    Last publish

    Collaborators

    • localhost9k
    • teamcc