mirror of
https://github.com/akveo/ngx-admin.git
synced 2025-12-23 19:00:13 +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 { AfterViewInit, Component } from '@angular/core';
|
||||
import { AfterViewInit, Component, OnDestroy } from '@angular/core';
|
||||
import { NbThemeService } from '@nebular/theme';
|
||||
|
||||
declare const echarts: any;
|
||||
|
|
@ -12,17 +12,18 @@ const points = [300, 520, 435, 530, 730, 620, 660, 860];
|
|||
<div echarts [options]="option" class="echart"></div>
|
||||
`,
|
||||
})
|
||||
export class TrafficChartComponent implements AfterViewInit {
|
||||
export class TrafficChartComponent implements AfterViewInit, OnDestroy {
|
||||
|
||||
type: string = 'month';
|
||||
types = ['week', 'month', 'year'];
|
||||
option: any = {};
|
||||
themeSubscription: any;
|
||||
|
||||
constructor(private theme: NbThemeService) {
|
||||
}
|
||||
|
||||
ngAfterViewInit() {
|
||||
this.theme.getJsTheme().delay(1).subscribe(config => {
|
||||
this.themeSubscription = this.theme.getJsTheme().delay(1).subscribe(config => {
|
||||
|
||||
const trafficTheme: any = config.variables.traffic;
|
||||
|
||||
|
|
@ -142,4 +143,8 @@ export class TrafficChartComponent implements AfterViewInit {
|
|||
});
|
||||
});
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
this.themeSubscription.unsubscribe();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue