Add (input) to html tag dynamically in Typescript


I have some html that is dynamically generated – I cannot modify it directly.

In this html is an <input class="MyInputClass"> with class specified (without id) and many other atrributes. I would like to handle this input (it’s text) so that it does something (let’s say: writes itself to console) when something is written to this input.

If I had an access to this in html I would do it like this:

<input type="text" class="form-control (input)="onSearchChange($">

public onSearchChange(searchValue : string ) {

Source: Angular 2 change event on every keypress

Is it possible to inject such handler?