Answer the question
In order to leave comments, you need to log in
How to set up 2 different modals for 1 button?
There is a header and there is a button in it, depending on which page is currently open, when clicking on the button, different modals should open. What is the best way to do this?
Now, when the button is clicked, a function is called, where the url of the page is checked and, depending on it, the necessary modal is called, but this is not entirely correct.
Answer the question
In order to leave comments, you need to log in
Create a service that stores the state of the application.
The necessary pages in ngOnInit tell the service that they have opened (you can take this.constructor.name
for example), the service remembers.
Then the service that opens the modal can ask for information about which page is open.
Binding to the router is not entirely correct, yes, although you can pull out not the url from the router, but the name of the component of the active page.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question