📎 Webclip
Mastering Component Communication in Angular
The post surveys the main ways Angular components communicate, comparing traditional decorators with newer signal-based APIs. It stays at the level of overview and points readers to code examples for each approach.
Reading notes#
- Covers input and output patterns, including decorators,
input()andoutput()functions, setters, inheritance, andngOnChanges. - Says
input()andoutput()improve performance and change detection, and thatmodel()unifies input and output for two-way binding. - Presents services as a shared hub for component communication, especially when provided in
root. - Uses template variables for direct parent-child access in templates, with reduced boilerplate but tighter coupling.
- Describes injected components as a rare pattern where a child injects its parent to call parent methods.
- Compares
@ViewChildand@ViewChildrenwithviewChild()andviewChildren()for accessing one or many elements in the view. - Explains
@ContentChildand@ContentChildrenwith<ng-content>, and their signal-based counterparts for projected content. - Reviews routing parameters, query parameters, component input binding with
withComponentInputBinding(), and router state objects as ways to pass data during navigation.
