Angular - Is There List Of HostListener-Events?


Answer :

Open angular dom element schema https://github.com/angular/angular/blob/master/packages/compiler/src/schema/dom_element_schema_registry.ts#L78

where:

  • (no prefix): property is a string.
  • *: property represents an event.
  • !: property is a boolean.
  • #: property is a number.
  • %: property is an object.

Then press ctrl+F and write *

enter image description here

@HostListener(and also (customEvent)="handler()") can also listen to custom events

Example


The list of events you can listen to can be found here

https://www.w3schools.com/jsref/dom_obj_event.asp

and I believe this one is the same, but better organized (I'm not sure if all are valid)

https://developer.mozilla.org/en-US/docs/Web/Events


Sorry, I think you ask about a list of properties. You can use e.g.

@HostListener("focus", ["$event.target"])   onFocus(target) {     console.log(target.value)   }    @HostListener("blur", ["$event.target"])   onBlur(target) {     console.log(target.value)    }   @HostListener("input", ["$event.target.value"])   onInput(value) {     console.log(value)    } 

Comments

Popular posts from this blog

Are Regular VACUUM ANALYZE Still Recommended Under 9.1?

Can Feynman Diagrams Be Used To Represent Any Perturbation Theory?