Reputation: 184
When I try to use hostListeners inside a Directive in my directive.ts, it throws me error: arguments of type {'selector':string, 'hostListeners':{};} is not assignable
...bla bla...
import { Directive, ElementRef, Input, Renderer, HostListener, OnInit, TemplateRef, ViewContainerRef } from '@angular/core';
@Directive({
selector: '[moduleOpt]',
hostListeners: {
}
})
export class ModuleOpt implements OnInit{
@Input() moduleOpt: Array<any>;
constructor(){}
ngOnInit() {
}
}
Can someone help me with this?
Upvotes: 1
Views: 221
Reputation: 657761
@Directive({
selector: '[moduleOpt]',
host: {
'(xxx)': 'yyy'
}
})
or
class MyDirective {
@HostListener('xxx', ['$event'])
yyy(event) {
console.log(event);
}
}
Upvotes: 2