Files
angular__angular/aio/content/guide
Andrew Scott 4962a4a332 feat(router): Allow loadChildren to return a Route array (#45700)
This commit expands the `LoadChildrenCallback` to accept returning `Routes`
in addition to the existing `NgModule` type. In addition, it adds a
check to ensure these loaded routes all use standalone components.
The components must be standalone because if they were not,
we would not have the required `NgModule` which the component is declared in.

Existing API:
```
{path: 'lazy/route', loadChildren: import('./lazy').then(m => m.LazyModule)}

@NgModule({
  imports: [
    ExtraCmpModule,
    RouterModule.forChild([
      {path: 'extra/route', component: ExtraCmp},
    ]),
  ],
})
export class LazyModule {}
```

The new API for lazy loading route configs with standalone components
(no NgModule) is to expand `loadChildren` to allow returning simply a `Routes` array.

```
// parent.ts
{
  path: 'parent',
  loadChildren: () => import('./children').then(m => m.ROUTES),
}

// children.ts
export const ROUTES: Route[] = [
  {path: 'child', component: ChildCmp},
];
```

Note that this includes minimal documentation updates. We need to
include a holistic update to the documentation for standalone components
in the future that includes this feature.

PR Close #45700
2022-04-22 09:25:20 -07:00
..
2022-04-08 19:36:30 +00:00
2022-04-08 19:36:30 +00:00
2022-04-19 09:26:12 -07:00
2022-04-08 19:36:30 +00:00
2022-04-08 19:36:30 +00:00
2022-04-08 19:36:30 +00:00
2022-04-08 19:36:30 +00:00
2022-04-08 19:36:30 +00:00
2022-04-08 19:36:30 +00:00
2022-04-08 19:36:30 +00:00
2022-04-08 19:36:30 +00:00
2022-04-08 19:36:30 +00:00
2022-04-08 19:36:30 +00:00
2022-04-08 19:36:30 +00:00
2022-04-08 19:36:30 +00:00
2022-04-08 19:36:30 +00:00
2022-04-08 19:36:30 +00:00
2022-04-08 19:36:30 +00:00
2022-04-08 19:36:30 +00:00
2022-04-08 19:36:30 +00:00
2022-04-08 19:36:30 +00:00
2022-04-08 19:36:30 +00:00
2022-04-08 19:36:30 +00:00
2022-04-08 19:36:30 +00:00