sarpay
12/9/2019 - 7:10 PM

ElementRef

import { ViewChild, ElementRef } from '@angular/core';

@Component({
    templateUrl: './controlNumberReports.component.html',
    encapsulation: ViewEncapsulation.None,
    animations: [appModuleAnimation()]
})

export class ControlNumberReportsComponent extends AppComponentBase {

  @ViewChild('WorldMap', { static: true }) WorldMap: ElementRef;
  
  constructor(
    injector: Injector
  ) {
    super(injector);
  }
  
  ngOnInit(): void {
    console.log(this.WorldMap.nativeElement.offsetWidth);
    this.WorldMap.nativeElement.style.height = chartHeight + 'px';
  }
  
}
<div #WorldMap class="row align-items-center">
  <google-chart [data]="geoChart"></google-chart>
</div>
<div #ControlNumberAutoComplete>
  <div class="form-group">
  </div>
<div>
import { AfterViewInit, ElementRef } from '@angular/core';

export class ControlNumbersReportComponent extends AppComponentBase implements AfterViewInit {
  @ViewChild('ControlNumberAutoComplete', { static: true }) ControlNumberAutoComplete: ElementRef;

  ngAfterViewInit(): void {
    const parentElements: HTMLElement[] = [
      this.ControlNumberAutoComplete.nativeElement
    ];
    for (let i = 0; i < parentElements.length; i++) {
      var parentStyle = window.getComputedStyle(parentElements[i], null);
      const childElement: HTMLElement = parentElements[i].querySelector('.form-group');
      childElement.style.position = 'fixed';
      childElement.style.width = parentStyle.width;
      childElement.style.zIndex = '1';
    }
  }
}
import { AfterViewInit, ElementRef } from '@angular/core';

export class ControlNumbersReportComponent extends AppComponentBase implements AfterViewInit {
  @ViewChild('CountryCodesFilterElement', { static: true }) CountryCodesFilterElement: ElementRef;

  getFilterData(): void {
    this._controlNumbersReportServiceProxy.getCountries()
      .subscribe(countries => {
        this.updateMultiselectFilter(this.CountryCodesFilterElement);
      });
  }

  updateMultiselectFilter(elementRef: ElementRef<any>): void {
    const el: HTMLElement = elementRef.nativeElement.querySelector('div.ui-multiselect');
    el.click();

    const closeBtnHtmlElement: HTMLElement = <HTMLScriptElement>el.querySelector('.ui-multiselect-close');
    closeBtnHtmlElement.click();

    const items: HTMLElement[] = [];
    const ulElems = el.querySelectorAll('.ui-multiselect-item');
  }
}