Daniel Stephens
Daniel Stephens

Reputation: 3209

How to handle generic routes in Angular?

I use Angular 9.17 and have a conceptual question.

I have implemented a login mechanism which can now be enabled for certain routes. The "home/start" page can of course be viewed logged in or logged out.

But depending on this, the view looks a lot different. So my question is, should i have two different components reflecting these views, or one and disabling/enabling certain elements depending on the signing-in status?

Are both approaches valid or is one of them an anti-pattern?

Upvotes: 0

Views: 72

Answers (1)

Maihan Nijat
Maihan Nijat

Reputation: 9344

There is no right or wrong answer to your question. I would share my experience of how I manage this situation. I hide certain elements if the user is not logged-in in those cases where I have a simple view but when it comes to complex view or too many things to hide or show then it's better you navigate user to different view if they are not logged-in.

Upvotes: 1

Related Questions