Good all the time of day! I am implementing an application using Deployd Server ( mongodb database) without a back-end . All logic is exceptionally angular .

Application routing is:

export const routes: Routes = [ { path: "", redirectTo: "weather", pathMatch: "full" }, { path: "weather", component: ClimateComponent}, { path: "news", component: NewsComponent}, { path: "login", component: LoginComponent, outlet: "user-router" }, { path: "registration", component: RegistrationComponent, outlet: "user-router" } ]; 

Thus, you can change the address bar, for example, by writing:

 http://localhost:4200/weather(user-router:registration) 

after which I turn to the component with registration. The problem is that after authorization, you can still enter in the address bar a route to register or authorize and they will open. How can you solve this? Will it be correct to use * ngIf for a router-outlet that contains registration and login, or use * ngIf directly in registration and login to block their contents? Perhaps there is a better solution?

    1 answer 1

    Found an answer to your question. To limit access to routes, you can use Guards. Maybe someone will come in handy, here's the source: metanit.com/web/angular2/7.7.php