angular / components

Component infrastructure and Material Design components for Angular
https://material.angular.io
MIT License
24.35k stars 6.74k forks source link

Document NgModule dependencies for components #15340

Closed JoeKahl closed 4 hours ago

JoeKahl commented 5 years ago

What is the expected behavior?

When following component examples, such as autocomplete, the only module mentioned as a dependency is MatAutocompleteModule. But in order to get the example code to work I also have to add FormsModule, MatInputModule, MatSelectModule and ReactiveFormsModule.

What is the current behavior?

Currently not all module dependencies are listed for examples. This wastes my time. Some of these dependencies do not give a compiler nor a run time error. The missing dependencies just make the code not work. I spend a lot of time reverting my work, going back to the example, as literally as I can. Eventually I get lucky and get an error message that leads to one missing dependency, then another. This process is not productive. Please consider listing all of the module dependencies for your examples.

What are the steps to reproduce?

Providing a StackBlitz reproduction is the best way to share your issue.
StackBlitz starter: https://goo.gl/wwnhMV

Which versions of Angular, Material, OS, TypeScript, browsers are affected?

"@angular/animations": "^7.2.1",
"@angular/cdk": "^7.2.1",
"@angular/common": "^7.2.1",
"@angular/core": "^7.2.1",
"@angular/forms": "^7.2.1",
"@angular/http": "^7.2.1",
"@angular/language-service": "^7.2.1",
"@angular/material": "^7.2.1",
"@angular/platform-browser": "^7.2.1",
"@angular/platform-browser-dynamic": "^7.2.1",
"@angular/router": "^7.2.1",

Is there anything else we should know?

tomgruszowski commented 5 years ago

This is one of the first complaints I hear from developers new to Material. StackBlitz examples tend to include all modules, making it harder to find out exactly what's needed.

Oddward commented 4 years ago

The documentation is definitely one of the biggest hurdles which was putting me off Angular & Angular Material, we always need to search further to find out why something really isn't working even if the code is exactly the same as given in the docs... add to that breaking changes that aren't communicated to devs in an accessible & clear way (or even have proper error messages).

jelbourn commented 4 years ago

(revisiting older issues as part of a triaging fix-it)

This is a good point; we should explicitly document the NgModule dependencies for the different components.

CristhianParra commented 3 years ago

@crisbeto @jelbourn I would like to help solving this issue, what do you think about adding the NgModule dependencies in this way?

imagen

Let me know if you like that desing, or what could be better, so I can start to work on it :)

jelbourn commented 3 years ago

I would probably do something that takes up less vertical space, more formatted roughly like

## API Reference for...
`import ...`

Depends on `FormsModule`, ...
amysorto commented 4 hours ago

Closing this issue since examples now use standalone components where imports are more clear instead of importing a common material module like before.