0Pricing
Angular Academy · Lesson

Building Reusable Behaviors

Package behavior as composable directives.

Behaviors as Building Blocks

The composition API shines when you design small, focused directives, each encapsulating one behavior, then compose them onto components as needed.

A Single-Purpose Directive

Keep each behavior tiny and standalone.

@Directive({
  selector: '[appElevate]'
})
export class ElevateDirective {
  @HostBinding('style.boxShadow')
  shadow = '0 2px 8px rgba(0,0,0,.15)';
}

All lessons in this course

  1. The hostDirectives Property
  2. Exposing Inputs and Outputs
  3. Building Reusable Behaviors
  4. Composition vs Inheritance
← Back to Angular Academy