Ionic Modal with router navigation - How to open modal with routing and close modal with routing and browser back button


I have ionic modal which is opened withing code after button click.
I pass parameters to this modal.

I want that when I open this modal programmatically the route will be /my-modal.

But also when the back button of the browser is activated then this modal closes, so I want it to subscribe to an “onBackEvent”.

I searched but nothing worked. How do I do that?