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:
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 _ngxZaloService: NgxZaloService) {
}
Login
<p ngxLoginZalo>Login Zalo</p>
login() {
this._ngxZaloService.login();
}
Logout
<p ngxLogoutZalo (successEvent)="logoutSuccessfullyAction()">Logout Zalo</p>
logout() {
this._ngxZaloService.logout().subscribe();
}
Update login info - Call this function in redirect page to store zalo info
constructor(private _router: Router, private _ngxZaloService: NgxZaloService) {
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);
}