Differenzansicht 14-lazyloading
im Vergleich zu 13-search

← Zurück zur Übersicht | Demo | Quelltext auf GitHub
src/app/app.routes.ts CHANGED
@@ -1,12 +1,18 @@
1
  import { Routes } from '@angular/router';
2
 
3
  import { HomePage } from './home-page/home-page';
4
- import { booksPortalRoutes } from './books-portal/books-portal.routes';
5
- import { booksAdminRoutes } from './books-admin/books-admin.routes';
6
 
7
  export const routes: Routes = [
8
  { path: '', redirectTo: 'home', pathMatch: 'full' },
9
  { path: 'home', component: HomePage, title: 'BookMonkey' },
10
- ...booksPortalRoutes,
11
- ...booksAdminRoutes
 
 
 
 
 
 
 
 
12
  ];
 
1
  import { Routes } from '@angular/router';
2
 
3
  import { HomePage } from './home-page/home-page';
 
 
4
 
5
  export const routes: Routes = [
6
  { path: '', redirectTo: 'home', pathMatch: 'full' },
7
  { path: 'home', component: HomePage, title: 'BookMonkey' },
8
+ {
9
+ path: 'books',
10
+ loadChildren: () => import('./books-portal/books-portal.routes')
11
+ .then(m => m.booksPortalRoutes)
12
+ },
13
+ {
14
+ path: 'admin',
15
+ loadChildren: () => import('./books-admin/books-admin.routes')
16
+ .then(m => m.booksAdminRoutes)
17
+ }
18
  ];
src/app/books-admin/books-admin.routes.ts CHANGED
@@ -3,6 +3,6 @@ import { Routes } from '@angular/router';
3
  import { BookCreate } from './book-create/book-create';
4
 
5
  export const booksAdminRoutes: Routes = [
6
- { path: 'admin', redirectTo: 'admin/create' },
7
- { path: 'admin/create', component: BookCreate, title: 'Create Book' }
8
  ];
 
3
  import { BookCreate } from './book-create/book-create';
4
 
5
  export const booksAdminRoutes: Routes = [
6
+ { path: '', redirectTo: 'create', pathMatch: 'full' },
7
+ { path: 'create', component: BookCreate, title: 'Create Book' }
8
  ];
src/app/books-portal/books-portal.routes.ts CHANGED
@@ -4,6 +4,6 @@ import { BookList } from './book-list/book-list';
4
  import { BookDetails } from './book-details/book-details';
5
 
6
  export const booksPortalRoutes: Routes = [
7
- { path: 'books', component: BookList, title: 'Books' },
8
- { path: 'books/details/:isbn', component: BookDetails, title: 'Book Details' },
9
  ];
 
4
  import { BookDetails } from './book-details/book-details';
5
 
6
  export const booksPortalRoutes: Routes = [
7
+ { path: '', component: BookList, title: 'Books' },
8
+ { path: 'details/:isbn', component: BookDetails, title: 'Book Details' },
9
  ];