Cookie Consent by Free Privacy Policy Generator Aktuallisiere deine Cookie Einstellungen ๐Ÿ“Œ โญAngular 17 Features โญ


๐Ÿ“š โญAngular 17 Features โญ


๐Ÿ’ก Newskategorie: Programmierung
๐Ÿ”— Quelle: dev.to

Hey there,

Version 17.0.0 is here and it has some great updates for Angular developers everywhere. ๐ŸŽ‰๐ŸŽ‰

TL;DR ๐Ÿ™Œ

โœ… Future-looking identity

โœ… Built-in control flow

โœ… Deferrable views

โœ… Revamped hybrid rendering experience

โœ… New @angular/ssr package

โœ… New lifecycle hooks

โœ… Vite and esbuild the default for new projects

โœ… Dependency injection debugging in DevTools

โœ… Improving Developer Experience

How to update to version 17

Visit update.angular.io for detailed information and guidance. To have the best update experience,

Update to 17

ng update @angular/cli @angular/core

In order to update your global angular,

npm i -g @angular/cli

Whatโ€™s in this release?

โœ… Future-looking identity

Image description

  • With Angular 17, developers can now access an updated documentation platform hosted on angular.dev
  • The new website has new structure, new guides, improved content, and built a platform for an interactive learning journey that will let you learn Angular and the Angular CLI at your own pace, directly in the browser.
  • Currently it is in beta preview and planning to make it the default website for Angular in v18.
  • Read more about it here ๐Ÿ‘‰ Blog post

โœ… Built-in control flow

  • The built-in control flow is available in v17 under developer preview today!
  • Angular 17 introduces a new block template syntax, enhancing the developer experience by offering powerful features
  • A new block template syntax that gives you powerful features with simple, declarative APIs are released
  • Under the hood, the Angular compiler transforms the syntax to efficient JavaScript instructions that could perform control flow, lazy loading, and more.
  • The built-in control flow enables:
    • More ergonomic syntax that is closer to JavaScript, thus more intuitive requiring fewer documentation lookups
    • Better type checking thanks to more optimal type narrowing
    • Itโ€™s a concept that primarily exists at build-time, which reduces the runtime footprint (making it โ€œdisappearingโ€) which could drop your bundle size by up to 30 kilobytes and further improve your Core Web Vital scores
    • It is automatically available in your templates without additional imports

โœ… Conditional statements

<div *ngIf="loggedIn; else anonymousUser">
  The user is logged in
</div>
<ng-template #anonymousUser>
  The user is not logged in
</ng-template>

With the built-in if statement, this condition will look like:

@if (loggedIn) {
  The user is logged in
} @else {
  The user is not logged in
}
  • Being able to provide the content for @else directly is a major simplification compared to the else clause of the legacy *ngIf alternative.
  • The current control flow also makes it trivial to have @else if, which historically has been impossible.
  • The improved ergonomics is even more visible with *ngSwitch:
<div [ngSwitch]="accessLevel">
  <admin-dashboard *ngSwitchCase="admin"/>
  <moderator-dashboard *ngSwitchCase="moderator"/>
  <user-dashboard *ngSwitchDefault/>
</div>

which with the built-in control flow turns into:

@switch (accessLevel) {
  @case ('admin') { <admin-dashboard/> }
  @case ('moderator') { <moderator-dashboard/> }
  @default { <user-dashboard/> }
}
  • The new control flow enables significantly better type-narrowing in the individual branches in @switch which is not possible in *ngSwitch.

โœ… Built-in for loop

@for (user of users; track user.id) {
  {{ user.name }}
} @empty {
  Empty list of users
}
  • We often see performance problems in apps due to the lack of trackBy function in *ngFor.
  • A few differences in @for are that track is mandatory to ensure fast diffing performance.
  • In addition, itโ€™s way easier to use since itโ€™s just an expression rather than a method in the componentโ€™s class.
  • The built-in @for loop also has a shortcut for collections with zero items via an optional @empty block.
  • The @for statement uses a new diffing algorithm and has more optimal implementation compared to *ngFor, which makes it up to 90% faster runtime for community framework benchmarks!

โœ… Deferrable views

  • Angular 17 introduces a concept known as deferrable views or @defer blocks
  • Deferrable views are available in developer preview in v17
  • Deferrable views bring performance and developer experience to the next level because they enable declarative and powerful deferred loading with unprecedented ergonomics.
@defer (on viewport) {
  <comment-list/>
} @loading {
  Loadingโ€ฆ
} @error {
  Loading failed :(
} @placeholder {
  <img src="comments-placeholder.png">
}
  • Thereโ€™s a ton of complexity under the hood that Angular manages for you.
  • Deferrable views offer a few more triggers:

    • on idle โ€” lazily load the block when the browser is not doing any heavy lifting
    • on immediate โ€” start lazily loading automatically, without blocking the browser
    • on timer(
    • on viewport and on viewport() โ€” viewport also allows to specify a reference for an anchor element. When the anchor element is visible, Angular will lazily load the component and render it
    • on interaction and on interaction() โ€” enables you to initiate lazy loading when the user interacts with a particular element
    • on hover and on hover() โ€” triggers lazy loading when the user hovers an element
    • when โ€” enables you to specify your own condition via a boolean expression
  • Deferrable views also provide the ability to prefetch the dependencies ahead of rendering them.

  • Adding prefetching is as simple as adding a prefetch statement to the defer block and supports all the same triggers.

@defer (on viewport; prefetch on idle) {
  <comment-list />
}

โœ… Revamped hybrid rendering experience

  • Angular 17 brings a revitalized hybrid rendering experience, offering robust server-side rendering (SSR) and static site generation (SSG) support

โœ… New @angular/ssr package

  • Angular Universal repository is moved to the Angular CLI repository and made server-side rendering an even more integral part
  • To add hybrid rendering support to your existing application run:
ng add @angular/ssr

โœ… New lifecycle hooks

  • 2 new life cycle hooks introduced in this release
    • 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
  • Only the browser will invoke these hooks, which enables you to plug custom DOM logic safely directly inside your components.

    โœ… Vite and esbuild the default for new projects

  • esbuild plus Vite powered build experience is enabled by default for all new applications
  • Benefits
    • A 67% improvement in build time.
    • An 87% speed improvement with SSR and SSG.
    • A lightweight and efficient build process.

โœ… Dependency injection debugging in DevTools

  • brand new debugging APIs are introduced that allow us to plug into the frameworkโ€™s runtime and inspect the injector tree.

  • Based on these APIs we built an inspection user interface that allows you to preview the:

    • Dependencies of your components in the component inspector
    • Injector tree and dependency resolution path
    • Providers declared within the individual injectors

โœ… Improving Developer Experience

Input value transforms

  • A common pattern is having a component which receives a boolean input.
  • This, however, sets constraints on how you can pass a value to such a component.
  • For example if we have the following definition of an Expander component:
@Component({
  standalone: true,
  selector: 'my-expander',
  template: `โ€ฆ`
})
export class Expander {
  @Input() expanded: boolean = false;
}

  • and we try to use it as
<my-expander expanded/>
  • Youโ€™ll get an error that โ€œstring is not assignable to booleanโ€.
  • Input value transforms allow you to fix this by configuring the input decorator:
@Component({
  standalone: true,
  selector: 'my-expander',
  template: `โ€ฆ`
})
export class Expander {
  @Input({ transform: booleanAttribute }) expanded: boolean = false;
}

Style and styleUrls as strings

  • Angular components support multiple stylesheets per component.
  • However, the vast majority of cases when I want to style my components I create an array with a single element pointing to the inline styles or referencing an external stylesheet
  • A new feature enables you to switch from *
@Component({
  styles: [`
    ...
  `]
})
@Component({
  styleUrls: ['styles.css']
})

to the simpler and more logical

@Component({
  styles:``
})
@Component({
  styleUrl: 'styles.css'
})

For more let us hear it from the creators

Credits : Official Announcement ๐Ÿ˜„

Changelog : Repository

...



๐Ÿ“Œ CVE-2023-26116 | angular angular.copy redos (SNYK-JS-ANGULAR-3373044)


๐Ÿ“ˆ 34.75 Punkte

๐Ÿ“Œ How to upgrade your Angular web project from Angular V13 to Angular V17


๐Ÿ“ˆ 34.75 Punkte

๐Ÿ“Œ Angular Addicts #25: Angular and Wiz will be merged, the differences between React and Angular & more


๐Ÿ“ˆ 34.75 Punkte

๐Ÿ“Œ Updates from the Angular Team and new Angular 17 features!


๐Ÿ“ˆ 28.76 Punkte

๐Ÿ“Œ Angular 5.1 zusammen mit Angular Material 5.0.0 erschienen


๐Ÿ“ˆ 23.17 Punkte

๐Ÿ“Œ ANGULAR 6 (FORMERLY ANGULAR 2) โ€“ THE COMPLETE GUIDE


๐Ÿ“ˆ 23.17 Punkte

๐Ÿ“Œ 7 steps to Angular Material Dialog instead of Angular Component


๐Ÿ“ˆ 23.17 Punkte

๐Ÿ“Œ Building a Dynamic Serverless Photo Blog with Angular & Google Sheets - 1: Solving Angular Router Navigation Issues


๐Ÿ“ˆ 23.17 Punkte

๐Ÿ“Œ CVE-2023-26117 | angular redos (SNYK-JS-ANGULAR-3373045)


๐Ÿ“ˆ 23.17 Punkte

๐Ÿ“Œ CVE-2023-26118 | angular redos (SNYK-JS-ANGULAR-3373046)


๐Ÿ“ˆ 23.17 Punkte

๐Ÿ“Œ Unveiling Angular 17 - The Angular Renaissance


๐Ÿ“ˆ 23.17 Punkte

๐Ÿ“Œ Episode 24/13: Native Signals, Details on Angular/Wiz, Alan Agius on the Angular CLI


๐Ÿ“ˆ 23.17 Punkte

๐Ÿ“Œ Google's New Angular 2.0 Isn't Compatible With Angular 1


๐Ÿ“ˆ 23.17 Punkte

๐Ÿ“Œ Google's New Angular 2.0 Isn't Compatible With Angular 1


๐Ÿ“ˆ 23.17 Punkte

๐Ÿ“Œ Angular Addicts #24: Angular 17.3, Signals and unit testing best practices, Storybook 8 & more


๐Ÿ“ˆ 23.17 Punkte

๐Ÿ“Œ rx-angular/state - a library for managing states of an Angular application


๐Ÿ“ˆ 23.17 Punkte

๐Ÿ“Œ Angular Series Part 1 Unlocking Angular Lifecycle Hooks: Your Path to Efficient Web Apps


๐Ÿ“ˆ 23.17 Punkte

๐Ÿ“Œ Angular se reinventa: Bienvenido a la era de Angular v18


๐Ÿ“ˆ 23.17 Punkte

๐Ÿ“Œ Angular Series Part 2 From Basics to Advanced: Exploring Angularโ€™s ngOnChanges


๐Ÿ“ˆ 23.17 Punkte

๐Ÿ“Œ Angular Addicts #26: Angular 18, best practices, recent conference recordings & more


๐Ÿ“ˆ 23.17 Punkte

๐Ÿ“Œ ANGULAR (FULL APP) WITH ANGULAR MATERIAL, ANGULARFIRE & NGRX


๐Ÿ“ˆ 23.17 Punkte

๐Ÿ“Œ How to Run Angular Apps Using Angular CLI and PM2


๐Ÿ“ˆ 23.17 Punkte

๐Ÿ“Œ Angular 17 Encrypting Decrypting Data with CryptoJs | Angular 17 Tutorial | React


๐Ÿ“ˆ 23.17 Punkte

๐Ÿ“Œ Angular Universal is the Problem, not Angular


๐Ÿ“ˆ 23.17 Punkte

๐Ÿ“Œ Angular is Much Better, But is Angular Universal?


๐Ÿ“ˆ 23.17 Punkte

๐Ÿ“Œ Accelerate Angular App Development with create-angular-auth-nav


๐Ÿ“ˆ 23.17 Punkte

๐Ÿ“Œ Implementing Angular Server-Side Rendering (SSR) AKA Angular Universal


๐Ÿ“ˆ 23.17 Punkte

๐Ÿ“Œ Next.js vs. Angular: Comparing key features and use cases


๐Ÿ“ˆ 17.17 Punkte

๐Ÿ“Œ What's New in Angular 16? Top features to discover.


๐Ÿ“ˆ 17.17 Punkte

๐Ÿ“Œ angular cli version 17 new features required


๐Ÿ“ˆ 17.17 Punkte

๐Ÿ“Œ โญAngular 16 Features โญ


๐Ÿ“ˆ 17.17 Punkte

๐Ÿ“Œ โญAngular 17 Features โญ


๐Ÿ“ˆ 17.17 Punkte

๐Ÿ“Œ โญAngular 18 Features โญ


๐Ÿ“ˆ 17.17 Punkte

๐Ÿ“Œ Exploring Angular 18: A Deep Dive into New Features and Comparisons with Previous Versions


๐Ÿ“ˆ 17.17 Punkte

๐Ÿ“Œ Angular 14: New Eye-Popping Features and Updates


๐Ÿ“ˆ 17.17 Punkte











matomo