🪟 Windows TippsThe Gemini desktop app is now available for Windows(11.09.2026 um 17:06 Uhr)
🔧 AI Nachrichten ChatGPT automatically logged out [Fix](12.09.2026 um 17:09 Uhr)
⚠️ Malware / Trojaner / VirenWindows 11 just dropped the tool ransomware abused, Microsoft says don’t restore WMIC(10.09.2026 um 20:11 Uhr)
🪟 Windows TippsServertimeout in Outlook über 10 Minuten verlängern(12.09.2026 um 15:10 Uhr)
🕵️ SicherheitslückenCVE-2026-11736 | NETGEAR XR1000v2 input validation(13.09.2026 um 03:22 Uhr)
🕵️ SicherheitslückenCVE-2026-11734 | NETGEAR RAX54Sv2 buffer overflow(13.09.2026 um 03:22 Uhr)
🪟 Windows TippsThe Gemini desktop app is now available for Windows(11.09.2026 um 17:06 Uhr)
🔧 AI Nachrichten ChatGPT automatically logged out [Fix](12.09.2026 um 17:09 Uhr)
⚠️ Malware / Trojaner / VirenWindows 11 just dropped the tool ransomware abused, Microsoft says don’t restore WMIC(10.09.2026 um 20:11 Uhr)
🪟 Windows TippsServertimeout in Outlook über 10 Minuten verlängern(12.09.2026 um 15:10 Uhr)
🕵️ SicherheitslückenCVE-2026-11736 | NETGEAR XR1000v2 input validation(13.09.2026 um 03:22 Uhr)
🕵️ SicherheitslückenCVE-2026-11734 | NETGEAR RAX54Sv2 buffer overflow(13.09.2026 um 03:22 Uhr)

🔧 Programmierung 🕛 vor 2 Jahren 2 Min Lesezeit
0

Angular Material Tabs with components inside the tabs

↗ Quelle (dev.to)
🗣️ Stimme:
📑 Inhaltsübersicht

My use case was to render components inside the Angular Material Tabs component. Despite searching online, I couldn't find any relevant resources, so I had to figure it out myself.



Below is the structure we want to use to define the components that should be displayed inside the tabs:




CODE
tabs = <Tab[]>[
{
label: 'Tab 1',
component: TabComponent,
data: {
title: 'Tab 1 Import information',
content: `Donec lacinia condimentum efficitur. Phasellus tempor est in luctus
facilisis.`,
},
},
{
label: 'Tab 2',
component: TabComponent,
data: {
title: 'Tab 2 Not so important...',
},
},
];









Component



Here's the complete code snippet for the component that renders the components inside the tab container.




CODE
type Tab = {
label: string;
component: Type<any>;
data: Record<string, any>;
};

@Component({
selector: 'app-tabcontainer',
standalone: true,
imports: [MatTabsModule],
templateUrl: './tabcontainer.component.html',
styleUrl: './tabcontainer.component.css',
})
export class TabcontainerComponent {
viewContainerRef = inject(ViewContainerRef);
tabs = <Tab[]>[
{
label: 'Tab 1',
component: TabComponent,
data: {
title: 'Tab 1 Import information',
content: `Donec lacinia condimentum efficitur. Phasellus tempor est in luctus
facilisis.`,
},
},
{
label: 'Tab 2',
component: TabComponent,
data: {
title: 'Tab 2 Not so important...',
},
},
];

ngOnInit() {
this.loadComponent(this.tabs[0]);
}

loadComponent(tab: Tab) {
this.viewContainerRef.clear();
const ref = this.viewContainerRef.createComponent<any>(tab.component);

// Pass on the props
for (const prop in tab.data) {
if (Object.prototype.hasOwnProperty.call(ref.instance, prop)) {
ref.instance[prop] = tab.data[prop];
}
}
}

onTabSelected(index: number) {
this.loadComponent(this.tabs[index]);
}
}









Caching the tabs



I conducted performance testing to see if caching the component references and loading them from the cache upon request would improve render time. However, there was no improvement in render time.






Angular signals



The code doesn't work with input() signals yet.






Demo



Try the stackblitz

Vollständiger Original-Bericht
Ausführliche Details, Code-Beispiele & Hersteller-Stellungnahme auf dev.to.
↗ Original-Artikel auf dev.to lesen
Wie bewertest du diesen Beitrag?
1 Klick Feedback
Teilen mit Netzwerk & Team:

Community-Analysen & Experten-Meinungen 0

Verfasse deine eigene Analyse, teile Workarounds oder diskutiere diesen Vorfall im Blog.
Noch keine Community-Analyse verfasst. Markiere einen Textabschnitt oder klicke oben auf Eigene Analyse verfassen“!
Community Pulse: Relevanz-Einschätzung
1 Klick Experten-Votum
🔴 Akute Relevanz 0%
🟡 In Evaluierung 0%
🟢 Keine Auswirkung 0%
Spannende Innovation 0%
Verwandte Story-Cluster & Quellen (Vektor-KI)
Port 8095 Engine
1 Quelle
Check Point Patches Critical VPN Vulnerabilities
1 Quelle
Ukrainian Conti Ransomware Developer Sentenced to 4 Years in US Prison
1 Quelle
GitLab Vulnerability Exploited One Day After Disclosure
Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten Angular Material Tabs with components inside the tabs

Thematisch verwandte Begriffe: Angular, Material, Tabs, with · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...