lazy loading

This commit is contained in:
Constantin Simonis 2025-02-18 08:52:00 +01:00
parent 10c8d02b77
commit c977d39565
Signed by: csimonis
GPG Key ID: 758DD9C506603183
3 changed files with 15 additions and 75 deletions

View File

@ -13,65 +13,5 @@ export class AppComponent implements OnInit {
ngOnInit() {
this.router.navigate(['hotels']);
const users = [
{
name: 'John',
age: 15,
},
{
name: 'Alice',
age: 16,
},
{
name: 'Bob',
age: 45,
},
{
name: 'Eve',
age: 29,
},
{
name: 'Charlie',
age: 52,
},
{
name: 'Dave',
age: 41,
},
{
name: 'Mallory',
age: 37,
},
{
name: 'Trent',
age: 48,
},
{
name: 'Peggy',
age: 26,
},
{
name: 'Victor',
age: 39,
},
];
from(users)
.pipe(
filter((user) => user.age >= 18),
reduce(
(acc, user) => {
acc.age += user.age;
acc.count++;
return acc;
},
{ age: 0, count: 0 },
),
map((data) => data.age / data.count),
)
.subscribe((data) => {
console.log('avg age: ', data);
});
}
}

View File

@ -6,17 +6,17 @@ import { CreateHotelComponent } from './hotel/component/create-hotel.component';
export const routes: Routes = [
{
path: 'hotels',
component: HotelsComponent,
loadComponent: () => import('./hotel/component/hotels.component').then((m) => m.HotelsComponent),
title: 'Hotels',
},
{
path: 'hotels/new',
component: CreateHotelComponent,
loadComponent: () => import('./hotel/component/create-hotel.component').then((m) => m.CreateHotelComponent),
title: 'New Hotel',
},
{
path: 'hotels/:hotelId',
component: HotelComponent,
loadComponent: () => import('./hotel/component/hotel.component').then((m) => m.HotelComponent),
title: 'Hotel',
},
];