Focusin event does not work

Asked

Viewed 42 times

1

I’m trying to use the event focusin in a Event Binding in Angular 4 and it does not return the expected for the event.

I added the event to a div and to test just launched a console.log (to see if it was activating) only that it does not return anything. When I change to event click it returns the message in the console, but neither the onfocus, nor the focusin worked.

On the HTML page:

<div class="col-md-3 col-sm-3 border" (focusin)="painelAtivado()"><label class="subtitulos">Execução</label>

In the component.ts:

painelAtivo(valor){
  this.flag = valor;
}
  • Did Divs have that event?

  • Note that the function has a different name: painelAtivo. Div does not receive Focus unless you add tabindex="0".

1 answer

0

I took the test on stackblitz and it seems to me that the function (focusis) works even within a div.

It seems to me that the function call is wrong. Then the code should be

the html:

<div class="col-md-3 col-sm-3 border" (focusin)="painelAtivo(false)">...

Browser other questions tagged

You are not signed in. Login or sign up in order to post.