Skip to content

Commit b334598

Browse files
committed
Lazy load bookings module
1 parent 04cbbfd commit b334598

File tree

5 files changed

+17
-13
lines changed

5 files changed

+17
-13
lines changed

projects/train-platform/src/app/app-routing.module.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { NgModule } from '@angular/core';
22
import { RouterModule, Routes } from '@angular/router';
33
import { BookingModule } from '../booking/booking.module';
4-
import { BookingComponent } from '../booking/booking/booking.component';
54
import { JourneySelectionComponent } from '../journey/journey-selection/journey-selection.component';
65
import { JourneyModule } from '../journey/journey.module';
76

@@ -13,9 +12,9 @@ const routes: Routes = [
1312
data: { title: 'Journeys' },
1413
},
1514
{
16-
path: 'bookings/journey/:journeyId',
17-
component: BookingComponent,
18-
data: { title: 'Book journey' },
15+
path: 'bookings',
16+
loadChildren: () =>
17+
import('./../booking/booking.module').then((m) => m.BookingModule),
1918
},
2019
];
2120

projects/train-platform/src/booking/booking/booking.component.ts renamed to projects/train-platform/src/booking/booking-form/booking-form.component.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ import { filter, map } from 'rxjs/operators';
77
import { BookingService } from '../booking.service';
88

99
@Component({
10-
selector: 'app-booking',
11-
templateUrl: './booking.component.html',
12-
styleUrls: ['./booking.component.css'],
10+
selector: 'app-booking-form',
11+
templateUrl: './booking-form.component.html',
12+
styleUrls: ['./booking-form.component.css'],
1313
})
14-
export class BookingComponent implements OnInit {
14+
export class BookingFormComponent implements OnInit {
1515
reserveSeat = false;
1616
firstClass = false;
1717
journeyId$!: Observable<string>;
Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,25 @@
1-
import { NgModule } from '@angular/core';
21
import { CommonModule } from '@angular/common';
2+
import { NgModule } from '@angular/core';
33
import { FormsModule } from '@angular/forms';
4-
import { BookingComponent } from './booking/booking.component';
54
import { RouterModule } from '@angular/router';
65
import { HotToastModule } from '@ngneat/hot-toast';
76
import { TranslateModule } from '@ngx-translate/core';
7+
import { BookingFormComponent } from './booking-form/booking-form.component';
88

99
@NgModule({
10-
declarations: [BookingComponent],
10+
declarations: [BookingFormComponent],
1111
imports: [
1212
CommonModule,
1313
FormsModule,
14-
RouterModule.forChild([]),
14+
RouterModule.forChild([
15+
{
16+
path: 'journey/:journeyId',
17+
component: BookingFormComponent,
18+
data: { title: 'Book journey' },
19+
},
20+
]),
1521
HotToastModule.forRoot(),
1622
TranslateModule.forChild(),
1723
],
18-
exports: [BookingComponent],
1924
})
2025
export class BookingModule {}

0 commit comments

Comments
 (0)