Answer the question
In order to leave comments, you need to log in
Event handling in angular2 controller?
The guys have an object passed to the component. It is necessary to hang event handling on this object. Can this be done in the controller and not in the template? For example, how to move the click to the controller?<div #test (click)="test()"></div>
Answer the question
In order to leave comments, you need to log in
like this
@Directive({
selector: 'blurFocus',
//при focus на элемент применяется класс focus
host: {
'(focus)': 'setInputFocus(true)',
'(blur)': 'setInputFocus(false)'
}
})
setInputFocus(isSet: boolean): void {
this.renderer.setElementClass(this.elementRef.nativeElement.parentElement, 'focus', isSet);
}
this.input$ = Observable
.fromEvent(this._el.nativeElement, 'input')
.debounceTime(500);
this.input$.subscribe(event=> this._check(event))
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question