question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[aio]: many mistakes in the NgModule guide

See original GitHub issue

I’m submitting a…


[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report  
[ ] Feature request
[x] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question

I have just read (again) the guide about NgModule on angular.io, and spotted many mistakes or problems.

  • https://angular.io/guide/ngmodules#the-basic-ngmodule:

    • implies that the CLI generates a module which imports FormsModule and HttpModule, which isn’t true.
  • https://angular.io/guide/ngmodule-vs-jsmodule:

    • implies that the CLI generates a module which imports FormsModule and HttpModule, which isn’t true.
  • https://angular.io/guide/frequent-ngmodules:

    • suggests using the deprecated HttpModule to talk to a server, instead of using HttpClientModule
  • https://angular.io/guide/module-types:

    • the section in the left menu is named “Types of NgModules”, whereas the page is titled “Types of Feature Modules”.
    • It lists “Feature Modules” as a prerequisite, although the section about Feature modules comes after this page in the left menu hierarchy.
    • It tells “Angular’s HttpModule is a good example of a service module”, although HttpModule is deprecated
  • https://angular.io/guide/entry-components:

    • still uses the deprecated HttpModule. Imports FormsModule, HttpModule and AppRoutingModule although they don’t bring anything useful to the understanding of entry components.
  • https://angular.io/guide/feature-modules#rendering-a-feature-modules-component-template:

    • Says “To see this HTML in the AppComponent, you first have to export the CustomerDashboardComponent in the CustomerDashboardModule. In customer-dashboard.module.ts, just beneath the declarations array, add an exports array containing CustomerDashboardModule:.” But the following example doesn’t have any export.
  • https://angular.io/guide/providers:

    • Says “This creates a service called UserService and returns a message telling you that you need to provide it.”. But no, the CLI doesn’t return such a message anymore.
    • Says: “Update app.module.ts by importing it with your other import statements at the top of the file and adding it to the providers array:”. But the following example doesn’t import the service, and doesn’t have any provider.
  • https://angular.io/guide/singleton-services#providing-a-singleton-service:

    • Says: “For example, a route will have an associated module. When the route is activated, an injector is created from that module as a child of the current injector. When you navigate away from the route, the injector is destroyed. This means that services declared in a route module will have a lifetime equal to that of the route.”. But what is a route module? The “Types of NgModule” page only describes what a “Routed feature module” and a “Routing module” are. But it doesn’t tell what a “route module” is. A concrete example showing how to limit the scope of a service to a route would be nice. There is no such explanation in the https://angular.io/guide/providers#provider-scope section, although that’s the one discussing how to limit the scope of a provider.
  • https://angular.io/guide/singleton-services#forroot:

    • Says “It also must be imported by the individual route components”. That’s not really correct: the components don’t import the RouterModule. Feature modules, containing components, are the ones that must also import the RouterModule.
    • Says “If the RouterModule didn’t have forRoot() then each route component would instantiate a new Router instance”. That is very unclear to me. Again: the guide shows how to limit the scope of a service to a component, by adding its provider to the component’s metadata. But that is not the case here, and it’s thus unclear why each route component would have its own Router instance.
    • Says “whereas all route components import RouterModule which does not include the Router”. But again, components don’t import modules. Modules do import modules.
  • https://angular.io/guide/lazy-loading-ngmodules#routes-at-the-app-level:

    • The default route redirects to itself, which doesn’t make much sense to me.
  • https://angular.io/guide/sharing-ngmodules:

    • The indentation in the imports of the example is messy
  • https://angular.io/guide/sharing-ngmodules#using-components-vs-services-from-other-modules:

    • missing space in sharedservices
  • https://angular.io/guide/ngmodule-faq#how-do-i-restrict-service-scope-to-a-module

    • contains {@ q-root-component-or-module}

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:4
  • Comments:16 (15 by maintainers)

github_iconTop GitHub Comments

1reaction
trotylcommented, Jan 17, 2018

@gkalpak I think you can continue with #21589 first, I’ll remove the conflict parts later. (AFAIK the official ones are always get merged quickly, so it would be better for users 😃 )

0reactions
angular-automatic-lock-bot[bot]commented, Jun 26, 2021

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

Read more comments on GitHub >

github_iconTop Results From Across the Web

NgModule FAQ
NgModules help organize an application into cohesive blocks of functionality. This page answers the questions many developers ask about NgModule design and ...
Read more >
angular.io guide content contains many documentation lint ...
angular.io guide content contains many documentation lint errors #47179 ... Open a topic from angular/angular/aio/content/guide · Review the commit message ...
Read more >
CUSTOM_ELEMENTS_SCHEMA added to NgModule. ...
I have a very simple app that has multiple components in a single module. I have added it to my module... I still...
Read more >
Angular Modules and NgModule - Complete Guide
we import a module and are trying to use its injectables but we start getting errors saying that the injectable is not available;...
Read more >
48 answers on StackOverflow to the most popular Angular ...
I've got the following error when launching my Angular app, even if the component ... In the same time Route & Navigation Guide...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found