Useful or not, from you.
angular Mat select in lazy loaded component throws a no provider error

🐞 bug report

Affected Package

@angular/material and maybe more

Is this a regression?

Not sure

Description

Importing MatSelectModule into a lazy-loaded component created with the component factory resolver throws an error.

ERROR Error: Uncaught (in promise): NullInjectorError: R3InjectorError(AppModule)[InjectionToken mat-select-scroll-strategy -> InjectionToken mat-select-scroll-strategy -> InjectionToken mat-select-scroll-strategy]: 
  NullInjectorError: No provider for InjectionToken mat-select-scroll-strategy!

🔬 Minimal Reproduction

Steps:

  • Create component A
  • Create component B
  • Lazy load component B with the component resolver factory into component A
  • Import MatSelectModule in component B
  • Use <mat-select> in component B

Result Error: No provider for InjectionToken mat-select-scroll-strategy!

Repo https://github.com/RogierdeRuijter/lazy-load-component-mat-select

🌍 Your Environment

Angular Version: Angular 9.0.0

That's a useful answer
Without any help

He,

Thanks for your response!

I will use the 2nd approach you mentioned.

Cheers