mirror of
https://github.com/akveo/ngx-admin.git
synced 2025-12-23 02:40:14 +01:00
fix(charts): unsubscribe when destroy component
This commit is contained in:
parent
08851fdfed
commit
549be765f0
19 changed files with 152 additions and 57 deletions
|
|
@ -1,4 +1,4 @@
|
|||
import { Component } from '@angular/core';
|
||||
import { Component, OnDestroy } from '@angular/core';
|
||||
import { NbThemeService, NbColorHelper } from '@nebular/theme';
|
||||
|
||||
@Component({
|
||||
|
|
@ -7,12 +7,13 @@ import { NbThemeService, NbColorHelper } from '@nebular/theme';
|
|||
<chart type="bar" [data]="data" [options]="options"></chart>
|
||||
`,
|
||||
})
|
||||
export class ChartjsBarComponent {
|
||||
export class ChartjsBarComponent implements OnDestroy {
|
||||
data: any;
|
||||
options: any;
|
||||
themeSubscription: any;
|
||||
|
||||
constructor(private theme: NbThemeService) {
|
||||
this.theme.getJsTheme().subscribe(config => {
|
||||
this.themeSubscription = this.theme.getJsTheme().subscribe(config => {
|
||||
|
||||
const colors: any = config.variables;
|
||||
const chartjs: any = config.variables.chartjs;
|
||||
|
|
@ -65,4 +66,8 @@ export class ChartjsBarComponent {
|
|||
};
|
||||
});
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
this.themeSubscription.unsubscribe();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue