Multi-Slot Projection with select
Project content into named slots.
Multi-Slot Projection with select is a free Angular Academy lesson on CoddyKit — lesson 2 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Angular Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
Multiple Slots
Many components need several regions: a header, a body, a footer. Angular supports this with multi-slot projection using the select attribute on <ng-content>.
The select Attribute
select takes a CSS selector. Each <ng-content select="..."> only projects nodes matching that selector.
<ng-content select="[card-header]"></ng-content>
<ng-content select="[card-body]"></ng-content>Selecting by Attribute
Attribute selectors are the most common pattern because they read cleanly in the consumer markup.
@Component({
selector: 'app-card',
template:
'<header><ng-content select="[header]"></ng-content></header>' +
'<main><ng-content select="[body]"></ng-content></main>'
})
export class CardComponent {}Consuming Named Slots
The consumer tags each piece of content with the matching attribute.
<app-card>
<h2 header>Title</h2>
<p body>Some body text here.</p>
</app-card>Selecting by Element or Class
You can also select by element name or CSS class.
<ng-content select="card-title"></ng-content>
<ng-content select=".highlight"></ng-content>The Catch-All Slot
An <ng-content> with no select captures everything that did not match a named slot. Place it last as a fallback.
<ng-content select="[header]"></ng-content>
<ng-content></ng-content>Order Matters
Angular evaluates slots in template order. Each projected node goes to the first matching slot. Put your catch-all after the specific selectors so it does not swallow everything.
Combining Selectors
CSS selectors can combine, e.g. select="button[primary]" targets a button element with a primary attribute.
<ng-content select="button[primary]"></ng-content>A Layout Component
Here is a card with header, body, and footer slots plus a catch-all.
@Component({
selector: 'app-card',
template:
'<header><ng-content select="[header]"></ng-content></header>' +
'<section><ng-content></ng-content></section>' +
'<footer><ng-content select="[footer]"></ng-content></footer>'
})
export class CardComponent {}Each Node Projects Once
A given projected node matches only one slot and is rendered exactly once. There is no way to clone the same node into two slots via projection.
Styling Per Slot
Because each slot lives in a distinct DOM location, you can wrap slots in styled containers (header/footer) to give each region its own look.
Quick Check
Test your knowledge of multi-slot projection.
Recap
You learned to build multi-slot components with <ng-content select="...">. Selectors can target attributes, elements, or classes; an unselected slot is the catch-all; and order determines which slot wins.
Frequently asked questions
Is the “Multi-Slot Projection with select” lesson free?
Yes — the full text of “Multi-Slot Projection with select” is free to read here on the web, and the Angular Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Angular Academy course, upgrade to CoddyKit PRO.
What will I learn in “Multi-Slot Projection with select”?
Project content into named slots. You practise Angular Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start Angular Academy?
No prior experience is required. Angular Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 2 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Multi-Slot Projection with select” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this Angular Academy lesson?
Yes. Every Angular Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- Single-Slot Content Projection
- Multi-Slot Projection with select
- ng-template and ng-container
- TemplateRef and ViewContainerRef