Routing w Angular¶
Wprowadzenie¶
System Masaku używa Angular Router z lazy loading dla modułów.
Konfiguracja routing¶
// app-routing.module.ts
const routes: Routes = [
{ path: '', redirectTo: 'dashboard', pathMatch: 'full' },
{
path: 'budgets',
loadChildren: () => import('@msk/budgets').then(m => m.BudgetsModule),
canActivate: [AuthGuard]
},
{
path: 'clients',
loadChildren: () => import('@msk/clients').then(m => m.ClientsModule)
}
];
Guards¶
@Injectable()
export class AuthGuard implements CanActivate {
canActivate(): Observable<boolean> {
return this.store.select(UserState.isAuthenticated);
}
}
Lazy Loading¶
Wszystkie feature moduły są lazy-loaded dla lepszego performance.