File
Implements
Metadata
selector |
ngx-auth |
styleUrls |
auth.component.scss |
template |
<nb-layout>
<nb-layout-column>
<nb-card>
<nb-card-body>
<div class="flex-centered col-xl-4 col-lg-6 col-md-8 col-sm-12">
<router-outlet></router-outlet>
</div>
</nb-card-body>
</nb-card>
</nb-layout-column>
</nb-layout>
|
Methods
ngOnDestroy
|
ngOnDestroy()
|
|
|
Private
alive
|
alive:
|
Default value : true
|
|
authenticated
|
authenticated: boolean
|
Type : boolean
|
Default value : false
|
|
subscription
|
subscription: any
|
Type : any
|
|
import {Component, OnDestroy} from '@angular/core';
import {takeWhile} from 'rxjs/operators';
// import {NbAuthService} from '@nebular/auth';
@Component({
selector: 'ngx-auth',
styleUrls: ['./auth.component.scss'],
template: `
<nb-layout>
<nb-layout-column>
<nb-card>
<nb-card-body>
<div class="flex-centered col-xl-4 col-lg-6 col-md-8 col-sm-12">
<router-outlet></router-outlet>
</div>
</nb-card-body>
</nb-card>
</nb-layout-column>
</nb-layout>
`,
})
export class NgxAuthComponent implements OnDestroy {
private alive = true;
subscription: any;
authenticated: boolean = false;
token: string = '';
// showcase of how to use the onAuthenticationChange method
constructor() {
// this.subscription = auth.onAuthenticationChange()
// .pipe(takeWhile(() => this.alive))
// .subscribe((authenticated: boolean) => {
// this.authenticated = authenticated;
// });
}
ngOnDestroy(): void {
this.alive = false;
}
}
Legend
Html element with directive