mirror of
https://github.com/akveo/ngx-admin.git
synced 2026-02-03 07:01:48 +01:00
refactor(components): ViewChild instead of querying dom
This commit is contained in:
parent
b05f525a7c
commit
d1307b8f58
4 changed files with 10 additions and 15 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 {Chartist} from './baChartistChart.loader.ts';
|
||||
|
||||
|
|
@ -18,14 +18,10 @@ export class BaChartistChart {
|
|||
@Input() baChartistChartClass:string;
|
||||
@Output() onChartReady = new EventEmitter<any>();
|
||||
|
||||
constructor (private _elementRef:ElementRef) {
|
||||
}
|
||||
@ViewChild('baChartistChart') private _selector:ElementRef;
|
||||
|
||||
ngAfterViewInit() {
|
||||
let el = this._elementRef.nativeElement.querySelector('.ba-chartist-chart');
|
||||
|
||||
let chart = new Chartist[this.baChartistChartType](el, this.baChartistChartData, this.baChartistChartOptions, this.baChartistChartResponsive);
|
||||
let chart = new Chartist[this.baChartistChartType](this._selector.nativeElement, this.baChartistChartData, this.baChartistChartOptions, this.baChartistChartResponsive);
|
||||
this.onChartReady.emit(chart);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
<div class="ba-chartist-chart {{baChartistChartClass || ''}}"></div>
|
||||
<div #baChartistChart class="ba-chartist-chart {{baChartistChartClass || ''}}"></div>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue