Develop Angular v21 components, services, and directives with signals. Use when implementing standalone components, OnPush change detection, inject() function, and input()/output() functions.
Development guide for components, services, and directives based on Angular v21 modern patterns.
When NOT to use:
tailwindcss-v4-stylinganalogjs-developmentmaterial-design-3-expressivestandalone: true in decorator, it's default)changeDetection: ChangeDetectionStrategy.OnPushsignal(), computed(), effect()inject() function instead of constructor injectioninput() / output() functions instead of @Input() / @Output() decoratorshost object instead of @HostBinding / @HostListener@if / @for / @switch instead of *ngIf / *ngFor / *ngSwitch[class] binding instead of ngClass[style] binding instead of ngStylePatterns to apply when creating components:
changeDetection: ChangeDetectionStrategy.OnPush in @Component decoratorinput() / output() functionscomputed()@if / @for / @switch control flow in templatesโ Details: Component Examples
Patterns to apply when creating services:
@Injectable({ providedIn: 'root' }) for singletoninject() functionsignal(), expose with asReadonly()computed()set() or update() (do NOT use mutate())โ Details: Signal Patterns
Patterns to apply when implementing forms:
FormBuilder via inject()getRawValue()ReactiveFormsModule to importsโ Details: Component Examples
Host binding implementation patterns:
@HostBinding / @HostListener decoratorshost object in @Component / @Directive decoratorโ Details: Component Examples
Patterns to apply when displaying images:
NgOptimizedImage (not for inline base64 images)width / height attributespriority attribute for above-the-fold imagesโ Details: Component Examples
changeDetection: ChangeDetectionStrategy.OnPush set?input() / output() functions used?inject() function?signal(), computed()) used?For detailed patterns and code examples, see: