[英]Destroy ng2-charts before navigating to another component
在銷毀之前檢查圖表是否存在:
應用程序組件.ts
import {BaseChartDirective} from 'ng2-charts';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
})
export class AppComponent implements OnDestroy {
@ViewChild('barChart') chart: BaseChartDirective;
ngOnDestroy() {
if (this.chart) this.chart.ngOnDestroy();
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.