Hostlistener to listen to a variable

Asked

Viewed 100 times

-1

I’m trying to implement an event HostListener to listen to a variable change.

I have an example that’s working, but you’re listening to the whole page and I just want to hear a little piece of code.

This is the part I want to hear:

<select class = "intenção-retângulo" (change) = "listQuantity = $ event.target.value">
    <opção [ngValue] = "10" valor = "10"> 10 </ option>
    <opção [ngValue] = "25" value = "25"> 25 </ option>
    <opção [ngValue] = "50" value = "50"> 50 </ option>
    <opção [ngValue] = "100" valor = "100"> 100 </ option>
</select>

This is my HostListener current one that is working:

@HostListener('document:click', ['$event']) onNumEachPageChange($event) {
   this.setArrayPages()
}

1 answer

0


You can do it like this:

<select class="intenção-retângulo" (change)="onClick($event.target.value)">
   <option></option>
</select>

It will call the method by clicking the select

onClick(data: any) {
        console.log('data', data)
}

Browser other questions tagged

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