Angular 2 obtener referencia del elemento host
¿Cómo puedo obtener la referencia del elemento host en angular 2? En mi caso quiero saber que en mi componente si tiene un foco o no. Es posible?
Saludos cordiales!
25
Author: bucicimaci, 2016-05-23
1 answers
Se obtiene la referencia del elemento host usando
class MyComponent {
constructor(private elRef:ElementRef) {
console.log(this.elRef.nativeElement);
}
}
También puede suscribirse al evento focus
class MyComponent {
@HostBinding() tabindex = 0;
@HostListener('focus', ['$event'])
onFocus(event) {
console.log(event);
}
}
47
Author: Günter Zöchbauer,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-05-23 06:14:17
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-05-23 06:14:17