I am new to angular and i am trying to figure out routing system
i have app.routes.ts
import { Routes } from "@angular/router";
export const routes: Routes = [
{
path: "",
loadComponent: () => import("./app").then((m) => m.App),
resolve: {},
title: "Login",
},
{
path: "home",
loadComponent: () =>
import("./containers/home/home.component").then((m) => m.HomeComponent),
resolve: {},
title: "HOME!",
},
];
my app basically does the authentication with backend:
export class App implements OnInit {
private authService = inject(AuthenticationService);
isLoggedIn = signal<boolean>(false);
constructor() {
this.authService.initAuth().subscribe({
next: (res) => {},
error: alert,
});
this.authService.isLoggedIn$.subscribe((isLoggedIn) => {
this.isLoggedIn.set(isLoggedIn);
});
}
ngOnInit(): void {}
}
my app.html:
@if(isLoggedIn()){
<div class="grid h-dvh w-dvw grid-cols-[auto_1fr] grid-rows-[auto_1fr_auto]">
<div class="row-span-3">
<c-sidebar />
</div>
<c-header />
<main class="bg-blue-50">
<router-outlet></router-outlet>
</main>
<c-footer />
</div>
}@else{
<c-login></c-login>
}
for some reason when i log in i get to see main content nested twice: