Upgrade to Pro — share decks privately, control downloads, hide ads and more …

The Angular Renaissance: Architectures with Mod...

The Angular Renaissance: Architectures with Modern Angular

Manfred Steyer

May 12, 2023
Tweet

More Decks by Manfred Steyer

Other Decks in Programming

Transcript

  1. @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
  2. @ManfredSteyer @Component({ standalone: true, imports: [ […], FlightCardComponent, CityPipe, CityValidator,

    ], selector: 'flight-search', templateUrl: '…' }) export class FlightSearchComponent { […] }
  3. @ManfredSteyer @Component({ standalone: true, imports: [ […], FlightCardComponent, CityPipe, CityValidator,

    ], selector: 'flight-search', templateUrl: '…' }) export class FlightSearchComponent { […] }
  4. @ManfredSteyer It looks like you want to use NgIfDirective and

    MyComponent. Shall I import it for you?
  5. @ManfredSteyer Restricting Access b/w Domains, etc. on a folder basis

    Credits to: Rainer Hahnekamp, AngularArchitects @softarc/eslint-plugin-sheriff
  6. @ManfredSteyer export const APP_ROUTES: Routes = [ […] { path:

    'flight-booking', canActivate: [() => inject(AuthService).isAuthenticated()], component: FlightBookingComponent }, ]
  7. @ManfredSteyer export const APP_ROUTES: Routes = [ […] { path:

    'flight-booking', canActivate: [() => inject(AuthService).isAuthenticated()], component: FlightBookingComponent }, ]
  8. @ManfredSteyer export const APP_ROUTES: Routes = [ […] { path:

    'flight-booking', canActivate: [() => inject(AuthService).isAuthenticated()], resolve: { flights: () => inject(FlightService).findAll() }, component: FlightBookingComponent }, ]
  9. @ManfredSteyer flights: Flight[] = []; const flights = await this.flightService.findAsPromise(from,

    to); this.flights = flights; <div *ngFor="let f of flights"> <flight-card [item]="f" /> </div>
  10. @ManfredSteyer 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>
  11. @ManfredSteyer Fine-grained and Zone-less CD Convertible to Observables and vice

    versa! No need to unsubscribe! No need to update code!