bug(MatTabGroup): StaticInjectorError thrown when using MatTabGroup with wrapper component
See original GitHub issueReproduction
See this Stackblitz
Create a component that includes a MatTabGroup
whose MatTab
come inside ng-content
<mat-tab-group #tabGroup>
<ng-content></ng-content>
</mat-tab-group>
Expected Behavior
The MatTabGroup
should not give an error, as it was the case with Angular 10 / Angular Material 10.
See this stackblitz for a working example with Angular 10 / Angular Material 10
Actual Behavior
The following error is thrown:
Error: StaticInjectorError(AppModule)[MatTab -> InjectionToken MAT_TAB_GROUP]:
StaticInjectorError(Platform: core)[MatTab -> InjectionToken MAT_TAB_GROUP]:
NullInjectorError: No provider for InjectionToken MAT_TAB_GROUP!
Environment
- Angular: 11.1.1
- CDK/Material: 11.1.1
- Browser(s): Tested in Chrome and Firefox
- Operating System (e.g. Windows, macOS, Ubuntu): Tested on macOS and Ubuntu
Issue Analytics
- State:
- Created 3 years ago
- Reactions:3
- Comments:11 (2 by maintainers)
Top Results From Across the Web
Angular Material Tabs not working with wrapper component
Using the components of MatTabModule directly works like a charm, whereas when using our custom components the projected content does not show ...
Read more >Tabs - Angular Material
MatTabGroup. Material design tab-group component. Supports basic tab pairs (label + content) and includes animated ink-bar, keyboard navigation, ...
Read more >Components Issue Mat Tab Group Wrapper Working With ...
Issue template for @angular/material.
Read more >Implement Lazy Loading with Mat Tabs in Angular - Medium
ts file for the component we need to lazy load. Project Setup. Here, we set up our project. We will be using the...
Read more >Create a dynamic tab component with Angular | juri.dev
Within our AppComponent we can now reference our tabs component ( <my-tabs> ) as well as the ng-template by using Angular's @ViewChild ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I ‘fixed’ the issue by providing the MAT_TAB_GROUP token in the wrapper component:
Merging the fix itself isn’t that difficult, but releasing the changes and updating the docs takes a while.