Skip to content

Instantly share code, notes, and snippets.

@eugene-ilyin
Created February 13, 2019 14:15
Show Gist options
  • Save eugene-ilyin/d5c456eef79c5792509e4e7bcaca93d1 to your computer and use it in GitHub Desktop.
Save eugene-ilyin/d5c456eef79c5792509e4e7bcaca93d1 to your computer and use it in GitHub Desktop.
import {Component, Directive, ElementRef, QueryList, ViewChildren} from "@angular/core";
// DON'T FORGET TO DECLARE A DIRECTIVE IN YOUR MODULE.
// Selector by class
@Directive({selector: '.live-screen__user-microphone'})
export class microphoneIconSelector {
// Define a property to make it available in object, returned by directive.
nativeElement: any;
constructor(private element: ElementRef) {
this.nativeElement = element.nativeElement;
}
}
@Component({
selector: 'pr-component',
template: require('./component.component.html'),
})
export class Component {
@ViewChildren(microphoneIconSelector) tooltipMicrophoneElems: QueryList<microphoneIconSelector>;
ngAfterViewInit() {
this.tooltipMicrophoneElems.forEach(item => {
// item.nativeElement is available for interactions
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment