Lock in $30 Savings on PRO—Offer Ends Soon! ⏳

Modern Angular: Renovation for Your Applications

Modern Angular: Renovation for Your Applications

Manfred Steyer

October 24, 2024
Tweet

More Decks by Manfred Steyer

Other Decks in Programming

Transcript

  1. @ManfredSteyer Agenda #1 esbuild #2a Standalone Components #2b Standalone APIs:

    Router & Http #3 Signals #4 SSR & Hydration #5 Control Flow & @defer
  2. @ManfredSteyer About me… Manfred Steyer, ANGULARarchitects.io (Remote) Angular Workshops and

    Consulting Google Developer Expert for Angular Blog, Books, Articles, and Talks about Angular Manfred Steyer
  3. @ManfredSteyer NgModules + EcmaScript Modules import { NgModule } from

    '@angular/core'; import { BrowserModule } from '@angular/platform-browser'; import { AppComponent } from './app.component'; […] @NgModule({ imports: [BrowserModule, OtherModule], declarations: [AppComponent, OtherComponent, OtherDirective], providers: [], bootstrap: [AppComponent], }) export class AppModule {} TypeScript Modules Angular Modules
  4. @ManfredSteyer Standalone Components @Component({ standalone: true, imports: [ […], FlightCardComponent,

    CityPipe, CityValidator, ], selector: 'flight-search', templateUrl: '…' }) export class FlightSearchComponent { […] }
  5. @ManfredSteyer Standalone Component → NgModules @Component({ standalone: true, selector: 'app-root',

    imports: [ […] TicketsModule, ], templateUrl: '…' }) export class AppComponent { }
  6. @ManfredSteyer Standalone Component → NgModules @Component({ standalone: true, selector: 'app-root',

    imports: [ […] TicketsModule, ], templateUrl: '…' }) export class AppComponent { }
  7. @ManfredSteyer NgModule → Standalone Blocks @NgModule({ imports: [ FlightCardComponent, ],

    declarations: [ MyTicketsComponent ], }) export class TicketsModule { }
  8. @ManfredSteyer NgModule → Standalone Blocks @NgModule({ imports: [ FlightCardComponent, ],

    declarations: [ MyTicketsComponent ], }) export class TicketsModule { }
  9. @ManfredSteyer Component With Signals flights = signal<Flight[]>([]); const flights =

    await this.flightService.findAsPromise(from, to); this.flights.set(flights); <div *ngFor="let f of flights()"> <flight-card [item]="f" /> </div>
  10. @ManfredSteyer NGRX Signal Store export const FlightBookingStore = signalStore( {

    providedIn: 'root' }, withState({ from: 'Paris', to: 'London', […] }), […] );
  11. @ManfredSteyer NGRX Signal Store export const FlightBookingStore = signalStore( {

    providedIn: 'root' }, withState({ from: 'Paris', to: 'London', […] }), withComputed(([…]) => ({ […] })), withMethods(([…]) => ({ })), withHooks({ […] }) );
  12. @ManfredSteyer @if @if(auth.userName) { <h2>Welcome {{auth.userName}}!</h2> } @else if(auth.trial) {

    <h2>Welcome to this trial version!</h2> <p>Please sign up to get the full version!</p> } @else { <h2>Welcome!</h2> <p>Please log in!</p> }
  13. @ManfredSteyer @for @for(f of flights; track f.id) { <flight-card [item]="f"

    [(selected)]="basket[f.id]" /> } @empty { <p>No flights found!</p> }
  14. @ManfredSteyer Summary esbuild: Build Performance Standalone: Simplicity APIs for Router

    & Http: Simplicity Signals: Reactivity & Performance SSR: Simplicity & Initial Page Load Control Flow & @defer: Simplicity & Performance
  15. @ManfredSteyer Contact and Downloads [web] ANGULARarchitects.io [twitter] ManfredSteyer d Slides

    & Examples Remote Company Workshops and Consulting http://angulararchitects.io