Overview
Feature | Description | Example | State |
---|---|---|---|
new output api |
a more streamlined output api |
old: @Output() updateParentName = new EventEmitter<string>(); new: updateParentName = output<string>(); tutorial: output |
stable |
Deferred view | A new mechanism of lazy load | @defer (on viewport) { |
preview(detail) |
New control flow | a new syntax for control flow | @if(condition) { |
comments |
New logo
Future looking documentation
https://www.angular.io -> https://www.angular.dev The new interactive learning experience is powered by WebContainers
Built-in Control flow
@if, @for, @switch
Benefit of new control flow
- More ergonomic syntax that is closer to JavaScript, fewer documentation lookups.
- Better type checking thanks to more optimal type narrowing.
- Exists in build time which reduces runtime footprint. drop you bundle size by up to 30k.
- Automatically available without any imports.
- Performance improvements.
Deferrable views
Enable SSR in new project
From Angular 17, when you create a project with ng new
, you can enable SSR by adding --ssr
flag.
1 | ng new my-app --ssr |
If you didn’t provide --ssr
option, Angular will ask you to choose whether .
Hydration graduate from developer preview
Hydration is now enabled by default for all applications using SSR.
Add hydration to existing project
If you have an existing project and want to add hydration, you can use the following command.
1 | ng add @angular/ssr |
New lifecycle hooks
The following lifecycle hooks are used to improve the performance of Angular’s SSR and SSG.
afterRender
- register a callback to be invoked each time the application finishes rendering.afterNextRender
- register a callback to be invoked the next time the application finishes rendering.
Vite and ESBuild default for new projects
From Angular 17, when you create a new project, the default build tool will be Vite and ESBuild.
Experimental view transitions support
1 | bootstrapApplication(App, { |
Defer loading of the animation module
1 | import { provideAnimationsAsync } from '@angular/platform-browser/animations-async'; |
Input value transforms
1 | // child.component.ts |
1 | // parent.component.ts |
The following code will cause an error: Type “” is not assignable to type “boolean”.
1 | <!-- parent.component.html --> |
to use flag before Angular 17, you need to use the following code:
1 | <!-- parent.component.html --> |
From Angular 17, you can use the first format with some extra configuration in ChildComponent. In this way Angular will automatically convert the flag attribute to a boolean value.
1 | // child.component.ts |
Style and styleUrls as string
You don’t need to use array for styles
and styleUrls
anymore.
before:
1 | ({ |
after:
1 | ({ |
Use fetch
as backend of HttpClient
1 | // app.config.ts |