New things to look out for in Angular v15:
The latest version of Angular has introduced numerous improvements and new capabilities. We've also gained optimization for older features released in Angular 14 or before. Here are the new features that are included in Angular version 15.
Standalone Components API:
Standalone components APIs allow the developer to build their Angular applications or projects without the need of defining NgModules. The introduction of standalone component APIs in Angular 14 was a great feature but lacked stability. Now that the feature has been thoroughly examined, tested, and improved, it has become more stable. Developers can use standalone APIs to start an application with a single component. Also, in Angular 15 the standalone APIs work across the Angular board. Meaning it works properly with routers, HttpClient, Angular Elements, and more.
Directive Composition API:
One of the major demands of the developers was something that allows them to reuse their directives. Most developers choose frameworks that have tools for reusing UI logic. The user interface (UI) is a crucial component of the web development process, and the latest Angular release has introduced the Directive Composition API, which allows for easy reusability. The directives may now be incorporated into the host components, making reusability in big projects very simple and effective. This saves a lot of time when developing a large-scale project where designs need to be reused.
Multi-Routed Applications:
Angular 15 also brought along router standalone APIs. Developers will be able to design a multi-routed application by simply employing the new APIs. You can easily assign the routes to it by first using it to load the root component and then directly allocating all of the routes in the root component. The bundlers will also remove all the unused or unnecessary features at build time, causing the size of the package to reduce in the final application bundle.
Image Directive stability:
The image directive is now production ready. The directive NgOptimizedImage is something that was introduced in Angular 14. Although valuable, it was not entirely polished to the state where we could utilize it in Angular 15. There are new additions or adjustments to the input names as well. The input rawSrc is now ngSrc, and the input rawSrcset is ngSrcset. The use of ngSrcset can help reduce the time taken for the images to be downloaded. The directive now includes a new input called "fill," which replaces the height and weight attributes. It is a Boolean input that is used as an inline style, forcing the image to be filled in its immediate parent container.
Functional router guards:
The use of functional routers is very useful as it helps reduce the extra boilerplate code. We can simply call or inject functions instead of using the older method of describing the service into a function and invoking that function. We can simply use the inject() method and add our service and the function of the service that we want to use. This cuts down a lot of extra code and makes it very easy to add authentication on routes in our application.
Cleaner Error stack traces:
The new update improves the appearance of the faults. In prior Angular versions, the error that was thrown merely displayed the library where the problem occurred, which increased debugging durations for developers at times. With the updated Angular 15 it will show a more precise location of the error by tracing the development code rather than just showing a list of libraries, reducing the time needed to locate and resolve the error.
Stable MDC Components:
A lot of the Angular 15 update is about stability. Adding to the list is the stability update to MDC components. The team has focused on making sure the MDCs used for designing Angular applications are improved in terms of accessibility. There are other changes as well in terms of DOM and CSS rule changes that might affect older applications.
Automatic imports using Language Service:
Now the developers can write lines of code without worrying about importing their components in templates. This is a minor yet convenient update for developers.