I want to tell you something about new Angular Features. Angular started 2023 very fast, Even some Angular developers call it Angular Renaissance 😂 Angular team is announcing new features every day. I would like to give some examples about new features coming to Angular.
You must have seen the ExpressionChangedAfterItHasBeenChecked error in Angular. This error is caused by the ZoneJS Change detection strategy in Angular. The Angular Team has been trying to reduce the ZoneJS dependency for a long time. We understand this from the pull requests that appear on the Angular GitHub account. Signal offers a pretty good feature to reduce dependency on ZoneJS.
Signals are the cornerstone of reactivity. They contain values that change over time (like RxJS Subject); when you change a signal’s value, it automatically updates anything that uses it.
Signals can be used anywhere, not just in components, which plays well with Angular’s dependency injection system.
You can also convert an observable to a signal. Or you can convert a signal to observable.
Signal-Based Components
To create signal-based components, first of all, it is necessary to change the signal property in the Component decorator to true.
If we set the signals to false, we will have created a zone-based component.
Signal is bringing fine-grain reactivity. The view knows exactly where the change has occured and can only refresh its view and not the entire component tree.
so no need of onpush anymore
Component Lifecycle and Effects
Zone-based components support eight different Class-Based lifecycle methods that let you hook into different stages of Angular’s change detection. Because these methods are tightly coupled to Angular current change detection model, they don’t make sense for signal-based components.
Vite For Angular
Minko Gechev announced that Angular will be using Vite for the development server of ng serve!
Functional guards and resolvers
Angular now supports functional guards and resolvers.
Hydration
Angular ngIf and ngFor will be hydratable soon.
NgCC Compiler
Angular Compatibility Compiler (ngcc) has been removed and as a result Angular View Engine libraries will no longer work.