Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IncludeStylesModule expects RouterModule to be imported. #87

Closed
cdchow opened this issue Nov 20, 2018 · 3 comments
Closed

IncludeStylesModule expects RouterModule to be imported. #87

cdchow opened this issue Nov 20, 2018 · 3 comments

Comments

@cdchow
Copy link

cdchow commented Nov 20, 2018

Hi,

As noted in the issue title, the IncludeStylesModule, which is bundled in the OrigamiModule, expects the RouterModule to be imported at some point. Simply adding it to my app.module.ts like this RouterModule.forRoot([]) would address the issue.

See a truncated error log below:

ERROR Error: StaticInjectorError(AppModule)[Router]: 
  StaticInjectorError(Platform: core)[Router]: 
    NullInjectorError: No provider for Router!

For additional context, I'm working on a hybrid AngularJS/Angular application that uses @uirouter/angular-hybrid. Using RouterModule in any way (even importing it in an @NgModule) makes the app complain and error (a different error, related to RouterModule). In the meantime, I've broken down our OrigamiModule import and instead imported its constituent modules, but excluding the IncludeStylesModule.

Agnostic of my issue, it seems like any Angular app that uses UIRouterModule instead of the default RouterModule would encounter this same error with IncludeStylesModule. I do not have a direct ask but wanted to surface the hard dependency on RouterModule.

Thanks.

@asyncLiz
Copy link
Collaborator

Hi @cdchow! Yes, the IncludeStylesModule does require the Angular router, since it prepares lazy-loaded components to enable the use of Polymer style modules in them.

Your solution to not import OrigamiModule and instead import the individual modules you use is the correct one.

Is the request to document the @angular/router dependency more clearly, or find a solution that does not require it? Right now if someone uses @uirouter/angular-hybrid, they would be unable to use the @IncludeStyles() decorator.

It might not be a bad idea to think of ways to configure IncludeStylesModule to accept different types of routers outside of the Angular one, or to disable hooking into the Angular router entirely.

@cdchow
Copy link
Author

cdchow commented Nov 20, 2018

Thanks @asyncLiz. Yes, exactly that, to document the dependency more clearly. 🙏

asyncLiz added a commit that referenced this issue Feb 3, 2019
@asyncLiz
Copy link
Collaborator

asyncLiz commented Feb 3, 2019

I've added more documentation, as well as an alternative IncludeStylesNoRouterModule that can be used instead of the one that requires @angular/router.

@asyncLiz asyncLiz closed this as completed Feb 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants