#Is it possible to have an individual component be rendered without the app.component.html template?

2 messages · Page 1 of 1 (latest)

sour raven
#

I have a login component, and would like it to be rendered completely on its own, but have the rest of my components be rendered as normal?

split nexus
#

The AppComponent is the root of your application. You should render your LoginComponent inside your AppComponent as a ChildComponent of your AppComponent. All other Components are like a DashboardComponent or something else should be on a "Sibling"-Level.

A better way would be a Router (https://angular.io/guide/router-reference) with the right Paths in combination with an ContentGuard (https://angular.io/api/router/CanActivate).

The route should be something like this:
App

  • Login
  • {} <- canActivate here
    • OtherPageComponent_1
    • OtherPageComponent_2
    • OtherPageComponent_n