components: No provider for Overlay! StaticInjectorError(AppModule)[MatMenuTrigger -> Overlay]:
Bug, feature request, or proposal:
bug
What are the steps to reproduce?
I update from angular 5.x and cli 1.7.x and rxjs 5.x to v6rc.x
I only update in my module this MatMenuModule
and use it like:
<div *ngFor="let item of data">
<button mat-icon-button [matMenuTriggerFor]="appMenu"></button>
<mat-menu #appMenu="matMenu" [overlapTrigger]="false"
class="slds-dropdown slds-dropdown_left slds-dropdown_actions">
<ul class="slds-dropdown__list" role="menu">
<li (click)="onClickCreerPO.emit({bail:item, nature:'Rent'})">
<a href="javascript:void(0);">PO Loyer</a>
</li>
<li (click)="onClickCreerPO.emit({bail:item, nature:'AddedRent'})">
<a href="javascript:void(0);">PO Surplus</a>
</li>
</ul>
</mat-menu>
</div>
Before
It was working before update.
Current
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 10
- Comments: 44 (10 by maintainers)
Commits related to this issue
- fix(overlay): injection errors for scroll strategy providers in lazy-loaded modules Fixes injection errors being thrown by the overlay-based providers that have injection tokens for the default scrol... — committed to crisbeto/material2 by crisbeto 6 years ago
- fix(overlay): injection errors for scroll strategy providers in lazy-loaded modules Fixes injection errors being thrown by the overlay-based providers that have injection tokens for the default scrol... — committed to crisbeto/material2 by crisbeto 6 years ago
- fix(overlay): injection errors for scroll strategy providers in lazy-loaded modules Fixes injection errors being thrown by the overlay-based providers that have injection tokens for the default scrol... — committed to crisbeto/material2 by crisbeto 6 years ago
- fix(overlay): injection errors for scroll strategy providers in lazy-loaded modules Fixes injection errors being thrown by the overlay-based providers that have injection tokens for the default scrol... — committed to crisbeto/material2 by crisbeto 6 years ago
- fix(overlay): injection errors for scroll strategy providers in lazy-loaded modules Fixes injection errors being thrown by the overlay-based providers that have injection tokens for the default scrol... — committed to crisbeto/material2 by crisbeto 6 years ago
- fix(overlay): injection errors for scroll strategy providers in lazy-loaded modules Fixes injection errors being thrown by the overlay-based providers that have injection tokens for the default scrol... — committed to crisbeto/material2 by crisbeto 6 years ago
- fix(overlay): injection errors for scroll strategy providers in lazy-loaded modules Fixes injection errors being thrown by the overlay-based providers that have injection tokens for the default scrol... — committed to crisbeto/material2 by crisbeto 6 years ago
- fix(overlay): injection errors for scroll strategy providers in lazy-loaded modules (#11213) Fixes injection errors being thrown by the overlay-based providers that have injection tokens for the defa... — committed to angular/components by crisbeto 6 years ago
I also fixed it by importing
OverlayModule
in myapp.module.ts
. ImportingOverlayModule
in lazy-loaded modules by the Router would’t work.i am still getting this error, although i have added OverlayModule in the AppModule. i even tried adding them to all the LazyLoad Modules, still no fix
Having similar issue due to [matTooltip]. Project was upgraded to 6 (release)
Hope it helps
After some tests, it appears it’s only happen in v6 when the module where
MatAutocomplete
is used is lazy-loaded.What about if importing OverlayModule at the app.module.ts isn’t an option? I am shipping a component as a library that uses material.
Importing OverlayModule at the library.module does not resolve the issue, only if I import it at the app.module of the project that uses my library… this would require the user to perform additional setup instead of just being able to import my library and use it right away,
Is there anyway around this?
import { Overlay } from ‘@angular/cdk/overlay’ in the spec file This fixed the issue for me
Same problem after updating to Angular 8.
Hello,
Although I am late to the post, I am facing the same issue.
I have created a showcase project for a library I’m coding. When using a custom overlay service that I wrote, I faced the error.
Simply providing my service into the module, instead of using
providedIn: root
solved the issue.I’m posting that just in case someone encounters the same issue in the same case.
Sorry I bothered you all !
@renatop7 you have right! The only way to get that thing working is to import
OverlayModule
in the app component (the root) module and not in the lazy loaded module… 🍰For everyone having problems with the
NullInjectorError: No provider for Overlay!
when trying to lazy load, just try to add OverlayModule to app.module imports, or your root module, for me it worked like a charm.It’s a temporary fix until they update the code…