mirror of
https://github.com/akveo/ngx-admin.git
synced 2025-12-17 07:50:12 +01:00
refactor(baAmChart): ViewChild instead of querying dom
This commit is contained in:
parent
8e82cc57ff
commit
b05f525a7c
2 changed files with 6 additions and 6 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
import {Component, ViewEncapsulation, Input, Output, ElementRef, EventEmitter} from '@angular/core';
|
import {Component, ViewChild, ViewEncapsulation, Input, Output, ElementRef, EventEmitter} from '@angular/core';
|
||||||
|
|
||||||
import './baAmChart.loader.ts';
|
import './baAmChart.loader.ts';
|
||||||
import {BaAmChartThemeService} from './baAmChartTheme.service';
|
import {BaAmChartThemeService} from './baAmChartTheme.service';
|
||||||
|
|
@ -15,7 +15,9 @@ export class BaAmChart {
|
||||||
@Input() baAmChartClass:string;
|
@Input() baAmChartClass:string;
|
||||||
@Output() onChartReady = new EventEmitter<any>();
|
@Output() onChartReady = new EventEmitter<any>();
|
||||||
|
|
||||||
constructor (private _elementRef:ElementRef, private _baAmChartThemeService:BaAmChartThemeService) {
|
@ViewChild('baAmChart') private _selector:ElementRef;
|
||||||
|
|
||||||
|
constructor (private _baAmChartThemeService:BaAmChartThemeService) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
|
@ -23,9 +25,7 @@ export class BaAmChart {
|
||||||
}
|
}
|
||||||
|
|
||||||
ngAfterViewInit() {
|
ngAfterViewInit() {
|
||||||
let el = this._elementRef.nativeElement.querySelector('.ba-am-chart');
|
let chart = AmCharts.makeChart(this._selector.nativeElement, this.baAmChartConfiguration);
|
||||||
|
|
||||||
let chart = AmCharts.makeChart(el, this.baAmChartConfiguration);
|
|
||||||
this.onChartReady.emit(chart);
|
this.onChartReady.emit(chart);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
<div class="ba-am-chart {{baAmChartClass || ''}}"></div>
|
<div #baAmChart class="ba-am-chart {{baAmChartClass || ''}}"></div>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue