Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

185
Views
Extending Angular Material2 MdTab component

I'm attempting to extend one of the Material components, MdTabGroup. Everything works fine with the out-of-the box MdTabGroup component - the material library is correctly imported into the module etc.

Here's the extended component:

@Component({
    selector: 'md-custom-tab-group',
    templateUrl: 'custom-tab-group.html',
    ....
})
export class MdCustomTabGroup extends MdTabGroup {
  constructor( private _r : Renderer) {
    super(_r);
  }
}

The new component is imported and declared in the app module, and is created thus:

<md-custom-tab-group>
    <md-tab>one</md-tab>
    <md-tab>two</md-tab>
</md-custom-tab-group>

The template for the custom tab group (custom-tab-group.html) is identical to the one in material, e.g.

<div class="mat-tab-body-wrapper" #tabBodyWrapper>
    <md-tab-body role="tabpanel"
                 *ngFor="let tab of _tabs; let i = index"
                 ...
                 [content]="tab.content"
                 ...>
    </md-tab-body>
</div>

When run, the _tabs ViewChildren collection is getting correctly populated - it consists of the md-tab declarations in the original markup, interpreted as a Material tab component. However, the custom-tab-group.html template is not valid. The template parser now doesn't know what 'md-tab-body' is.

Specifically -

Can't bind to 'content' since it isn't a known property of 'md-tab-body'.

but I don't think it knows what md-tab-body is at all when it picks up the new template.

The question is - how can I correct this behavior and get the extended component working?

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Not a good answer but this issue that is being tracked seems to be the root of it.

https://github.com/angular/material2/issues/9216

Once they include MatTabBody, MatTabHeader and MatTabLabelWrapper in the export list you should be able to extend it.

about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!