Search code examples
angulardialogpopupcomponents

For every dialog modal pop-up, should a new component be created? (Angular )


I have created an angular component for a dialog (using angular material). I need to create another dialog modal . for this, do I create another separate component?


Solution

  • It mostly depends on your intentions.

    If this modal would have a really similar behavior than the one you have already created, then most likely creating another component for that purpose would be unnecessary. Just send extra parameters that make your component customizable.

    If that modal has a totally different purpose, then, of course, create a new one.

    My tip is to always try to make everything clearly understandable/straight forward. Imagine that you are someone else who has to work with your code. Would you be able to understand what was the purpose of creating these components without asking? If the answer is yes, then you are probably on the right track.