Using multiple components in different modules causing "Type X is part of the declarations of 2 modules" error
See original GitHub issueI’m submitting a … (check one with “x”)
[ ] bug report
[x] feature request
[ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question
Current behavior
Right now you cannot import two directives of the same module
Expected/desired behavior
You can use same directives/components in multiple modules without errors.
What is the motivation / use case for changing the behavior?
Concept of the shared module with its shared resources is good for components that are used everywhere. But if you have a complex application (ours contain more then 50 modules and 1500 components, services and pipes all together) multiple components can be reused different way. For example QuestionListPage uses UserActiveListPanel from User module. Also PhotoListPage uses same UserActiveListPanel, and VideoListPage uses UserActiveListPanel. How do I reuse this panel? Best way is see is to provide it in directives
of the component as it was before rc.5. But right now I can’t do it. But I can create lets say UserShareModule and put it there… its good, but if I put everything that is used by other modules from user module, i’ll LOT of things there unnecessary in most of times. Then what to do? Create UserActiveListPanelShareModule? It will create lot of such trash files. So what to do? Maybe we simply can provide same directives multiple times without having this annoying error Type X is part of the declarations of 2 modules
?
If you tell me that its by design, then my answer is: in my opinion its a bad design.
Please tell us about your environment:
- Angular version: 2.0.0-rc.5
- Browser: [all ]
- Language: [all]
Issue Analytics
- State:
- Created 7 years ago
- Reactions:64
- Comments:98 (26 by maintainers)
Your question sounds like a support request.
Please use the issue tracker only for bugs and feature requests.
Use gitter and StackOverflow for support request.
as @brandonroberts saids, create a shared module like this:
then use the SharedModule like this…