@Input@Outputname input and nameChange output)@ViewChild(), @ViewChildren, @ContentChild and @ContentChildrenDefault change detection strategy
ng generate component the correct strategy will already be configuredreadonlyprivate and such that are used in template with protected.Historically the go-to tool for reactivity in Angular has been RxJS and observables. With Angular 17 a new reactive building block has been introduced: signals. Here are dos and don’ts to consider:
HttpClient API, since it encapsulates the parsing with io-ts and allows to execute the requests lazily (which won’t be the case with httpResource).computeds, no value$.pipe(take(1)).subscribe(value => ...)) and it is easy to define derived values with computed(() => ...).toSignal, but there are important things to note:
toSignal is not lazy, it subscribes to the observable (and causes the fetching of the data) no matter if the signal is read or not. The behavior can be compared to a “hot” observable.toLazySignal that only subscribes to the observable, when the signal is read.toSignal and toLazySignal only unsubscribe when the injector is destroyed (i.e. the component is destroyed), they won’t unsubscribe if the component stops using the signal due to a condition (@if) in the template.{ providedIn: "root" } should not use toSignal and toLazySignal, since these observables will never get unsubscribed, unless a “hot” observable is the desired behavior.toLazySignal when data fetching is involved.toLazySignal back with toObservable will cause them to be not lazy anymore.input and model signals allow to integrate in the reactive world nicely (no more Subject that is nexted in ngOnChanges). And also, they allow to mark inputs as input.required for a cleaner typing.