Answer the question
In order to leave comments, you need to log in
How to catch a custom DOM event in Angular2?
After the ngAfterViewInit event, I insert code into the DOM using jqvery.
$(this.elementRef.nativeElement).html('<div> <button id="foo" type="button" name="button">fire event</button> <script> $("#foo").on("click", function() { $(document).trigger("lorem"); }); </script> </div>');
$(document).on("lorem", function(event, param1, param2) { alert(param1 + param2); });
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question