I have two HTML elements below,
<p #test>with reference</p>
<p id="with-id">need to access without template reference</p>
I know I can access the first P element with the template reference with renderer2 but I am not sure how I access the second P tag without template reference.
In our case,
Our modal is served outside our angular app. I need to add a click event to the close button of the modal which I directly don't have access to.
Below is my code,
this.unlistenCloseButton = this.renderer2.listen('outside-html-element', 'close', event => {
console.log(`on close`);
});
Is there a way to add a reference to that close button and pass it to the angular's renderer2?
Here is a stackblitz code demonstrating with two P tag.
On the popup close, am not sure if you use jquery or just javascript, but you need to call this below code (when the modal closes). Which will create a custom event.
Then in the angular component listen for this document event using hostlistener.
Code taken for the answer here