E
E
Egor Sh2016-03-20 11:35:20
Angular
Egor Sh, 2016-03-20 11:35:20

Can I somehow make two components so that the routes pass first through one, and then through the other in Angular2?

Good afternoon! I'm making a website in Angular2.
I have a main component - AppComponent. I get into it initially when I go to the site. It has a routeconfig with paths, and html has . Everything seems to be fine, but my first page is the authorization page and it differs from the others. Is it possible to somehow make sure that the user is authorized on this page or not, and then if so, transfer it to another component that would be considered the starting one with its own route configs and route-outlet. Why do I want to do all this, I have an authorization page without a header, and for all the rest I need a header, i.e. I can't add something else to the AppСomponent template, because it will be immediately visible, and hiding it, it seems to me, is not a solution. Tell me how to do better?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey, 2016-03-20
Protko @Fesor

Now let's reread what you wrote and think. If you have an AppComponent, which is like your entire application, but there is some component (LoginForm) that has a different layout than AppComponent, etc. then it is logical to assume that AppComponent is not exactly a "top-level component", etc.
Authorization (or rather, whether the dude is authorized) is checked in route resolvers and not in components.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question