What's New in Angular 17 - Angular 17 - Yaay or Naay - by Thamodi Wickramasinghe - Feb, 2024 - Bits and Pieces
What's New in Angular 17 - Angular 17 - Yaay or Naay - by Thamodi Wickramasinghe - Feb, 2024 - Bits and Pieces
Search Write
Get unlimited access to the best of Medium for less than $1/week. Become a member
336 1
Angular always aims to please the developers with new versions.
This time, they have come up with Angular 17 with a new set of features that
aim to elevate the developer experience, boost performance, and provide
more tools for building scalable web applications.
Logo redesign
Angular.dev
Deferrable views
Signals: stable
Dev tools
Performance Improvements
Security Improvements
Logo Redesign
Angular Team rebranded the whole look of angular by redesigning the logo.
This is the first time the initial AngularJS 2012 logo has been updated.
Angular.dev
Along with the rebranding, the Angular Team changed their website as well.
@Component({
selector: 'app-root',
standalone: true,
imports: [CommonModule, RouterOutlet],
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
title = 'Control Flows Angular 17';
isUserAvailable: boolean = true;
}
1. Traditional Method
<h1>Angular 17</h1>
@if (isUserAvailable) {
<p>User available</p>
} @else {
<p>User Not available</p>
}
New control flows are similar to if-else conditions and easy to remember.
Angular 17 also provides @else if control flow, which makes development
easier.
<div [ngSwitch]="userLevel">
<admin-dashboard *ngSwitchCase="admin"/>
<moderator-dashboard *ngSwitchCase="moderator"/>
<user-dashboard *ngSwitchDefault/>
</div>
@switch (userLevel) {
@case ('admin') { <admin-dashboard/> }
@case ('moderator') { <moderator-dashboard/> }
@default { <user-dashboard/> }
}
Deferrable views
Angular 17 also introduced deferrable views using @deffer templates. Using
this template we can lazy load components when a condition is met. For
example, if we want to display a separate component, when “user scrolls to
that section” or “in 5 seconds” we can use @deffer templates. Let’s explain
the concept using an example.
We can use the @loading block to define what will be displayed till the
component is loaded. If no @loading block is defined, the default
placeholder will be displayed. Loading of the @defer block can be quite fast,
therefore, there can be a flickering effect with the @loading block. To avoid
that we can define the display duration of the @loading block using
after and minimum fields.
on viewport
on hover and on hover() — lazy load when the user hovers an element
With Angular 17, signals API has become stable. To know more about
Angular Signals, read the documentation here.
Dev Tools
Angular has introduced this cool new feature of viewing, “dependency
injection” in dev tools. Based on this feature, we can view the dependencies
of your components in the component inspector, injector tree, dependency
resolution path, and providers declared within the individual injectors.
Furthermore, the SSR package has been moved from Angular Universal to
the Angular/CLI repository.
@Component({
selector: 'my-chart-cmp',
template: `<div #chart>{{ ... }}</div>`,
})
export class MyChartCmp {
@ViewChild('chart') chartRef: ElementRef;
chart: MyChart|null;
constructor() {
afterNextRender(() => {
this.chart = new MyChart(this.chartRef.nativeElement);
}, {phase: AfterRenderPhase.Write});
}
}
...@Component({
styleUrls: ['styles.css']
})...
@Component({
styles: `
...
`
})
...@Component({
styleUrl: 'styles.css'
})
...
Performance Improvements
Android 17 introduces a set of performance improvements. As explained
earlier, using deferrable views, we can reduce the workload of change
detection. In previous versions, angular would process each element. With
deferrable views, we can eliminate that process, because Angular would
identify which component needs to be displayed at what time.
Security Improvements
Angular 17 focuses on, not only performance but also security. It has
introduced two new improvements.
Migration
Migration to Angular 17 is supposed to be as smooth as possible. We can use
ng update to upgrade the related dependencies. Angular strives to be
backward compatible with older versions. Even though, there may be
deprecations and breaking changes that require some adjustments during
migration. The best practice is to read the documentation before upgrading
to major versions. Furthermore, Angular update guide and migration tools
will assist you in managing the changes.
Conclusion
With the introduction of Angular 17, the Angular Team reaffirms its position
as a leading front-end framework.
Furthermore, they are already planning for the next major version and is
planning to include some great features. In the next release, they plan to
release Angular’s signal-based reactivity, hybrid rendering, and learning
journey.
We can expect more exciting features in Angular 18,
which has already been planned to be released in
May 2024.
Learn More
Thamodi Wickramasinghe in Bits and Pieces Vidura Senevirathne in Bits and Pieces
394 1 603 5
Chameera Dulanga in Bits and Pieces Thamodi Wickramasinghe in Bits and Pieces
831 3
773 7
See all from Thamodi Wickramasinghe See all from Bits and Pieces
231 1 281 2
Lists
193 7 66
195 180 5