Skip to content

Commit

Permalink
Merge branch 'master' of github.com:angular-checklist/angular-checkli…
Browse files Browse the repository at this point in the history
…st into i18n-step1-content-multiple-languages
  • Loading branch information
MSakamaki committed Jul 2, 2019
2 parents bc38586 + f27a943 commit 6b79c1b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Working with a shared module is quite common and recommended. This module can be

# Solution

When creating a `SharedModule`, we want to import the components in all feature modules but only only provide the services in our root module, for instance `AppModule`. We can accomplish this by leveraging the `forRoot` convention. Here's what our `SharedModule` would look like this:
When creating a `SharedModule`, we want to import the components in all feature modules but only provide the services in our root module, for instance `AppModule`. We can accomplish this by leveraging the `forRoot` convention. Here's what our `SharedModule` would look like this:

```ts
@NgModule({
Expand Down
8 changes: 6 additions & 2 deletions content/en-US/router/lazy-load-feature-modules.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ This means that the `UsersModule` will be added to the main bundle. The main bun
// app.routing.ts
const routes: Routes = [
...
{path: 'users', loadChildren: '../users/usersModule#UserModule'}
{
path: 'users',
loadChildren: () => import('../users/usersModule').then(m => m.UsersModule)
}
...
];

Expand All @@ -57,7 +60,8 @@ const routes: Routes = [
export class AppModule {}
```

We updated the `/users` route to use the `loadChildren` property. This points to the module file of the `UsersModule` and always has a fixed format: `${pathToModule}#${nameOfTheModule}`.
We updated the `/users` route to use the `loadChildren` property. This uses the standard dynamic import syntax.
Called as a function, the import returns a promise which loads the module.

Also note that we no longer add the `UsersModule` to the imports of the `AppModule`. This is important because otherwise lazy loading wouldn't work as expected. If the `UsersModule` was referenced by the `AppModule` the code for that module would be added to the main bundle.

Expand Down

0 comments on commit 6b79c1b

Please sign in to comment.