
Learn to build highly customizable Angular components using directives, content projection, ng-templates, design tokens, and dynamic views through the composable components pattern, enabling reusable, maintainable UI.
Advance from basic knowledge to pro-level component authoring in modern Angular, leveraging signals, standalone components, and the new dependency injection approach.
Practice along with ready-made starting projects to learn building reusable Angular components, following detailed instructions and targeted goals, and code along in your IDE or StackBlitz.
Discover how Angular uses directives to create small, reusable behaviors. Build custom directives from scratch, learn inputs, output events, and bind to host element aspects to reduce boilerplate.
Explore how selectors power directives and components in Angular, attaching them to unexpected elements to reveal surprising effects and the true capabilities beyond best practices.
Learn how content projection in Angular enables building components from smaller building blocks, a pattern for creating adaptable, customizable components for varied projects and changing requirements without rewriting code.
Explore how design tokens enable customizable styling for reusable Angular components like our expander, and learn how view encapsulation and content projection affect CSS.
Investigate view encapsulation in Angular, comparing global styles with component-scoped rules, and learn how private styles apply to a component while nested elements like expander remain unaffected, using dev tools.
Explore how Angular emulates view encapsulation by default, compare none and emulated settings, and see how CSS rules stay scoped to a component or bleed globally when none is chosen.
Learn how Angular emulates view encapsulation by adding unique ng-content and ng-host attributes to component elements, creating scoped CSS rules; with none, CSS becomes global.
Angular compiles TypeScript to main.js and translates component SCSS into CSS, then Angular rewrites selectors with unique component attributes to enable view encapsulation and per-component styling.
See how view encapsulation applies the owner component's style rules to projected content through unique identifiers, showing how content projection receives styling from the owner component.
Explore how the :host selector targets a component’s host element using ng-host, applies CSS to the host and its content via ng-content.
Explore how the :host-context selector in Angular applies styles to a host element when any ancestor matches a condition, enabling nested component styling via class or attribute like grayscale.
Discover how to style reusable angular components with css custom properties (design tokens), enabling external control of primary color, borders, radii, and shadows for flexible theming.
Learn best practices for styling reusable Angular components with CSS custom properties, using a public/private proxy pattern and component-prefixed names to enable flexible customization of header, border, and animation duration.
Derive expander colors from a single base color by computing baseLight, lighter, and baseTransparent with colorMix in srgb, using them as fallbacks while allowing explicit overrides.
Explore how to provide default styling for projected content in an Angular expander by using ng-deep to bypass view encapsulation, while balancing risks and best practices.
Use ng-deep only in the most specific nested container to style projected content, and expose css custom properties as design tokens to form a public api for external styling.
Explore templates in Angular to make components reusable by letting consumers customize the entire UI, including HTML and CSS.
Learn how ng-container, a container in Angular templates, acts as a ghost element to host directives without rendering a DOM node, enabling flexible, reusable components.
Explore ng-template and ng-container to understand how templates create reusable UI factories, render copies with ng-template-outlets, and implement highly customizable components in Angular.
Master how Angular templates function as reusable UI blocks by passing parameters such as caption and color using let variables and a context.
Angular provides shortcuts to simplify templates and assigns $implicit as the default public name for the main parameter. Use $implicit to pass the main data context to templates.
Learn to pass templates as inputs to Angular components by using template refs and ng-template, enabling reusable templates via a repeater component that renders each item with its data context.
Explore placing directives on ng-container and ng-template, learn how Angular provides element ref and template ref, and see how templates act as reusable html factories.
Apply hands-on programming to evolve a real Angular reusable component using templates, gaining control over its appearance and user interface structure while refining the boilerplate into a cleaner, flexible pattern.
Practice along to build a simple text editor app that uses ng-templates and ng-containers, and create a reusable item selector component with customizable display and selection using templates.
Create a reusable item selector component in Angular, placed in a shared folder for cross-project use, with a title, options, and banana-in-a-box two-way binding to the selected option.
Learn to let an Angular item selector accept an optional ng-template input and render each item with either the template or a default presentation.
Learn to pass templates as content in an Angular component using content child and template ref to customize item templates. Explore designating multiple role-specific templates for different parts.
Wrap a template with a directive to designate an item template using a dedicated attribute, enabling multi-template components and template access via template ref.
Target the item-template-directive with a content-child query to access the template through the directive. Define role-specific directives to support multiple templates and reveal exciting template syntax improvements.
Discover how the Angular star syntax turns directives into template wrappers, explaining structural directives like ng-if, desugaring to ng-template, and using let bindings for type-safe templates.
Make template references type-safe by defining an item template context with a read-only $implicit string and a static ng-template-context-guard to enable TypeScript type safety for the context.
Introduce an itemContainer directive (selector appItemContainer) to define the full container template. Provide an ItemContainerContext with item, isSelected, and onSelect to render and select the item.
Learn how to implement the item container logic in an Angular item selector using content child query, a template outlet, and CSS custom properties for dynamic styling.
Learn how to design Angular microsyntax for structural directives, focusing on API design with TypeScript, IntelliSense, and IDE integration, before connecting syntax to a real implementation in the next section.
Explore the microsyntax in Angular, learn how star directives create templates and alter the DOM structure, and define APIs for structural directives with minimal code.
Explain how microsyntax for the myRepeat directive translates a star into a template wrapper and how to populate inputs using a primary input and additional inputs with the myRepeat prefix.
Verify input values in Angular by using an effect to console.log repeat, start, and skip, showing that the values render correctly and enable data context for the template.
Discover how to build reusable Angular components with the myTimer directive, defining inputs for interval, from, to, and step, and rendering updated values in templates.
Define template variables in micro syntax to control how structural directives supply context data. Use let to bind values and expose exported names for repeats and timer contexts.
Learn to implement Angular's type guards with ngTemplateContextGuard to type the template context, improving intellisense and safety for micro-syntax and explicit syntax in repeat and timer contexts.
Base your template context on signals to automatically update as values change. Use read-only signals for numbers and time state to sync multiple template instances in zoneless Angular.
Define input aliases in microsyntax by adding a context property that matches the input name, enabling template variables like times and total, and reducing boilerplate.
Explore imitating legacy ng-if and ng-for with custom my-if and my-for directives, emphasizing type-safe context, aliasing with as, and track-by, plus lambda template expressions in Angular.
Learn to use generic types in TypeScript to infer directive item types, enforce type safety with my for and my if, and connect directives to their contexts via type guards.
Discover how modern Angular structural directives manipulate the DOM by creating and removing views with a view container ref, using signal-based APIs for dynamic and predictable UI.
Explore how Angular defines a view as the smallest ui unit created and destroyed, and see how embedded views and for loops generate multiple dynamic views with varying lifespans.
Discover how Angular creates views from templates, differentiate component templates and ng templates, and explore host and embedded views, DOM nodes, directives, element refs, and injector lifespan.
Host views are component instances with a host element, inputs, outputs, and their own injector; embedded views come from ng-templates and rely on a shared data context.
Explore view creation with the ViewContainerRef (VCR), generating embedded and host views from templates and components, and wield createEmbeddedView, createComponent, and ngTemplateOutlet.
Create dynamic embedded views from templates by injecting template ref and view container ref, supply a proper context, and render conditional content in Angular directives.
Implement the my-if directive in Angular using signals, effects, and a computed boolean to control an embedded view with ViewContainerRef; invalidate and synchronize on signal changes.
Narrow the my if context type by excluding falsy values, creating a truthy version of T that guarantees a non-null item in templates, using the Exclude utility.
Code along builds an Angular timer directive using template and view container refs, signals for interval and steps, and a derived running state to render a single context.
Implement a reactive timer in Angular by using effects to respond to input changes, manage a setInterval with onCleanup to clear previous intervals, and drive a signal from from-to-step inputs.
learn to implement the my-repeat structural directive in Angular, wiring viewContainerRef and template, and render li items based on count, start, and skip values with incremental updates.
Implement the myRepeat context for each item in angular structural directive, exposing index, first, last, and a myRepeat signal, with an implicit value from start and index, using incremental DOM.
Create a withDateLocale structural directive to supply a custom injector for embedded views, enabling MAD calendar to reflect locale changes by providing matDateLocale and a native date adapter.
Choose which component to render at runtime by creating components programmatically, enabling dynamic components in modern Angular for configuration-driven or server-driven data scenarios.
Components can be created at runtime from a type reference, either declaratively in a template or imperatively in code. We look at the view-switcher example we're going to build and walk through the starter code already in place.
NgComponentOutlet is a structural directive that renders a component from a type expression. We explore its syntax, available bindings, and how Angular manages the component's lifecycle automatically.
We use ngComponentOutletInputs to pass the products list into the active presenter. Each view reads the items through its signal input and renders the data.
NgComponentOutlet has no output binding mechanism. We learn how to create a custom Injector with an injection token and pass it via ngComponentOutletInjector to communicate actions back to the parent.
We define a ViewPicker interface requiring an options input and a value model. We create an injection token for the picker component type and provide a default SelectPickerComponent.
learn to anchor a view container reference to a specific UI location in the app component using ViewChild and a reference, reading for view container ref to insert hosted views.
We inject the picker type from the token and create it using ViewContainerRef.createComponent with inputBinding for the view options and twoWayBinding for the selected view. The picker now drives the presenter swap
Angular provides inputBinding, outputBinding, and twoWayBinding helpers to wire up dynamic components at creation time. We explore the syntax and see how they replace the old setInput approach.
Mastering Angular components is what separates average developers from true professionals.
This course is focused on turning you into an expert in component authoring in Angular 22. You’ll go beyond basic components and learn the advanced building blocks that Angular provides:
element directives,
structural directives,
microsyntax,
content projection,
templates,
dynamic view composition
and more importantly, how they all fit together into powerful, real-world patterns.
At the core of this course is a powerful pattern: Composable Components. Instead of building components that try to do everything with endless inputs and interfaces, you’ll learn how to design a lean “core” component that can be extended and customized using external pieces: templates, directives, and projected content. This approach keeps your components simple, while allowing them to grow in capability without becoming complex or fragile. This makes your components flexible across scenarios, without becoming bloated with options.
Instead of creating components that are rigid, overloaded with inputs, or filled with flags, you’ll learn how to design components that are truly flexible, composable, and scalable, the kind used in real-world component libraries and design systems.
You’ll start with element (attribute) directives, learning how to extend and enhance existing DOM elements. Then we dive into selector strategies and advanced selector patterns, giving you precise control over how your directives and components are applied.
Next, we move into content projection, where you’ll learn how to design components that accept external pieces and compose them into flexible layouts. From there, we cover styling and view encapsulation, understanding how Angular scopes styles and how to build components that can be themed and customized.
After that, we go deeper into templates with ng-template, TemplateRef, and ngTemplateOutlet, followed by Angular microsyntax, where you’ll understand how the * syntax works and how to design clean, intuitive directive APIs.
We then bring it all together with structural directives and view manipulation using ViewContainerRef, giving you full control over how views are created, updated, and managed at runtime. Finally, we cover dynamic components, completing the picture of fully flexible and programmable UI composition.
Throughout the course, everything is tied together into clear patterns you can apply immediately in your own projects.
By the end, you won’t just know Angular features, you’ll know how to use them together to build components like a pro.