170
rated 0 times
[
171]
[
1]
/ answers: 1 / hits: 8112
/ 8 Years ago, mon, august 8, 2016, 12:00:00
I want to pass an element reference to a directive. I know that the reference of the element on which the directive has been applied can be obtained by
private _elemRef: ElementRef
but I want to pass the reference to other element to the directive. Any help is appreciated.
Here's the demo code. I m using a ripple
directive.
<ul #other>
<li ripple>Hello</li>
</ul>
directive.js
@Directive({
selector: '[ripple]'
})
export class RippleDirective {
constructor(private _elemRef: ElementRef) {
}
@HostListener('click', ['$event'])
public onClick(event: MouseEvent) {
// I wan't to refer the '#other' node here
}
}
More From » angular