Differenzansicht 15-lazyloading
im Vergleich zu 14-directives

← Zurück zur Übersicht | Demo | Quelltext auf GitHub
src/app/admin/admin-routing.module.ts CHANGED
@@ -5,15 +5,16 @@ import { BookEditComponent } from './book-edit/book-edit.component';
5
 
6
  const routes: Routes = [
7
  {
8
- path: 'admin',
9
- redirectTo: 'admin/create'
 
10
  },
11
  {
12
- path: 'admin/create',
13
  component: BookCreateComponent,
14
  },
15
  {
16
- path: 'admin/edit/:isbn',
17
  component: BookEditComponent,
18
  }
19
  ];
5
 
6
  const routes: Routes = [
7
  {
8
+ path: '',
9
+ redirectTo: 'create',
10
+ pathMatch: 'full'
11
  },
12
  {
13
+ path: 'create',
14
  component: BookCreateComponent,
15
  },
16
  {
17
+ path: 'edit/:isbn',
18
  component: BookEditComponent,
19
  }
20
  ];
src/app/app-routing.module.ts CHANGED
@@ -13,6 +13,14 @@ const routes: Routes = [
13
  path: 'home',
14
  component: HomeComponent,
15
  },
 
 
 
 
 
 
 
 
16
  ];
17
 
18
  @NgModule({
13
  path: 'home',
14
  component: HomeComponent,
15
  },
16
+ {
17
+ path: 'books',
18
+ loadChildren: () => import('./books/books.module').then(m => m.BooksModule)
19
+ },
20
+ {
21
+ path: 'admin',
22
+ loadChildren: () => import('./admin/admin.module').then(m => m.AdminModule)
23
+ }
24
  ];
25
 
26
  @NgModule({
src/app/app.module.ts CHANGED
@@ -4,11 +4,9 @@ import { BrowserModule } from '@angular/platform-browser';
4
 
5
  import { AppRoutingModule } from './app-routing.module';
6
  import { AppComponent } from './app.component';
7
- import { BooksModule } from './books/books.module';
8
  import { HomeComponent } from './home/home.component';
9
  import { SearchComponent } from './search/search.component';
10
  import { AuthInterceptor } from './shared/auth.interceptor';
11
- import { AdminModule } from './admin/admin.module';
12
 
13
  @NgModule({
14
  declarations: [
@@ -20,8 +18,6 @@ import { AdminModule } from './admin/admin.module';
20
  BrowserModule,
21
  AppRoutingModule,
22
  HttpClientModule,
23
- BooksModule,
24
- AdminModule
25
  ],
26
  providers: [
27
  {
4
 
5
  import { AppRoutingModule } from './app-routing.module';
6
  import { AppComponent } from './app.component';
 
7
  import { HomeComponent } from './home/home.component';
8
  import { SearchComponent } from './search/search.component';
9
  import { AuthInterceptor } from './shared/auth.interceptor';
 
10
 
11
  @NgModule({
12
  declarations: [
18
  BrowserModule,
19
  AppRoutingModule,
20
  HttpClientModule,
 
 
21
  ],
22
  providers: [
23
  {
src/app/books/books-routing.module.ts CHANGED
@@ -6,11 +6,11 @@ import { BookListComponent } from './book-list/book-list.component';
6
 
7
  const routes: Routes = [
8
  {
9
- path: 'books',
10
  component: BookListComponent,
11
  },
12
  {
13
- path: 'books/:isbn',
14
  component: BookDetailsComponent,
15
  }
16
  ];
6
 
7
  const routes: Routes = [
8
  {
9
+ path: '',
10
  component: BookListComponent,
11
  },
12
  {
13
+ path: ':isbn',
14
  component: BookDetailsComponent,
15
  }
16
  ];