Event handling in the controller angular2?

Guys have the object passed into the component. Need to this object will hang event handling. Can it be done in the controller, not in the template? For example how to move click in the controller ?
<div #test (click)="test()"></div>
June 27th 19 at 15:28
1 answer
June 27th 19 at 15:30
for example
@Directive({
 selector: 'blurFocus',
 //when focus on the element used class focus
 host: {
 '(focus)': 'setInputFocus(true)',
 '(blur)': 'setInputFocus(false)'
}
})

and inside the class method itself
setInputFocus(isSet: boolean): void {
 this.renderer.setElementClass(this.elementRef.nativeElement.parentElement, 'focus', isSet);
 }

or hang a listener on a element of an Observable(here the listener to enter data in input)
this.input$ = Observable
 .fromEvent(this._el.nativeElement, 'input')
.debounceTime(500);
 this.input$.subscribe(event=> this._check(event))

Find more questions by tags Angular