lazy loading
This commit is contained in:
parent
10c8d02b77
commit
c977d39565
@ -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);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -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',
|
||||
},
|
||||
];
|
||||
|
Loading…
x
Reference in New Issue
Block a user