question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

tabs: nested mat-tab with matTabContent directive does not work

See original GitHub issue

Bug, feature request, or proposal:

Bug

What is the expected behavior?

Nested mat-tab with <ng-template matTabContent> to work

What is the current behavior?

Nested mat-tab with <ng-template matTabContent> do not work

What are the steps to reproduce?

https://stackblitz.com/edit/angular-material2-issue-aqmcu4?file=app/app.component.html

Use <ng-template matTabContent> in both the outer and the inner mat-tab and the issue will occur

<mat-tab-group>

  <mat-tab label="tab1">
    <ng-template matTabContent>
      
      <mat-tab-group>
        <mat-tab label="child tab1">
          <ng-template matTabContent>
            <p>Test Test Test Test Test Test Test Test Test Test Test Test</p>
          </ng-template>
        </mat-tab>

        <mat-tab label="child tab2">
          <ng-template matTabContent>
            <p>Test Test Test Test Test Test Test Test Test Test Test Test</p>
          </ng-template>
        </mat-tab>
      </mat-tab-group>

    </ng-template>
  </mat-tab>

  <mat-tab label="tab2">
    <ng-template matTabContent>
      <p>Test Test Test Test Test Test Test Test Test Test Test Test</p>
    </ng-template>
  </mat-tab>

  <mat-tab label="tab3">
    <ng-template matTabContent>
      <p>Test Test Test Test Test Test Test Test Test Test Test Test</p>
    </ng-template>
  </mat-tab>

</mat-tab-group>

What is the use-case or motivation for changing an existing behavior?

Which versions of Angular, Material, OS, TypeScript, browsers are affected?

Angular: 6.0.0 Material 6.3.0

Is there anything else we should know?

If <ng-template matTabContent> is removed from the inner mat-tab, it works

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:10 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
EBMikecommented, Mar 6, 2019

@robertmazzo nesting a mat-tab-group inside a mat-tab still breaks it… using your example, but updating the dynamic tabs with this will break

<mat-tab label="Dynamic Preferences">
	<ng-template matTabContent>
		<mat-tab-group>
			<mat-tab label="foo">
			        <ng-template matTabContent> // <-- this breaks it
			            bar
			        </ng-template>
			</mat-tab>
		</mat-tab-group>
	</ng-template>
</mat-tab>
2reactions
robertmazzocommented, Oct 1, 2018

I just tried adding nested mat-tab directives unsuccessfully. Any news on this ? thanks.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Mat Tabs Nested - StackBlitz
Tab group with asynchronously loading tab contents.
Read more >
Multiple nested dynamic Formgroups in multiple nested tabs
How can I achieve that every form in his own tab got an own reference to a Formgroup, which are dynamically generated? I've...
Read more >
Tabs - Angular Material
Angular Material tabs organize content into separate views where only one view can be visible at a time. Each tab's label is shown...
Read more >
Angular material tabs with lazy loaded routes - Zoaib Khan
Our tab sections need routes! The other problem with using the angular material tabs component is that we cannot link tab content to...
Read more >
Create a dynamic tab component with Angular | juri.dev
Note: we cannot reuse the same @ContentChildren mechanism because it only works for projected content which has to happen statically. Our tabs ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found