mirror of
https://github.com/akveo/ngx-admin.git
synced 2026-02-28 10:54:07 +01:00
refactor(demo): unsubscribe when destroy component
This commit is contained in:
parent
549be765f0
commit
cceabef8eb
12 changed files with 96 additions and 37 deletions
|
|
@ -1,4 +1,4 @@
|
|||
import { Component } from '@angular/core';
|
||||
import { Component, OnDestroy } from '@angular/core';
|
||||
import { NbThemeService } from '@nebular/theme';
|
||||
|
||||
@Component({
|
||||
|
|
@ -24,14 +24,19 @@ import { NbThemeService } from '@nebular/theme';
|
|||
</nb-card>
|
||||
`,
|
||||
})
|
||||
export class TrafficComponent {
|
||||
export class TrafficComponent implements OnDestroy {
|
||||
type: string = 'month';
|
||||
types = ['week', 'month', 'year'];
|
||||
currentTheme: string;
|
||||
themeSubscription: any;
|
||||
|
||||
constructor(private themeService: NbThemeService) {
|
||||
this.themeService.getJsTheme().subscribe(theme => {
|
||||
this.themeSubscription = this.themeService.getJsTheme().subscribe(theme => {
|
||||
this.currentTheme = theme.name;
|
||||
});
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
this.themeSubscription.unsubscribe();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue