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

Angular's Future without NgModules: Architectur...

Angular's Future without NgModules: Architectures with Standalone Components @ngConf

Manfred Steyer

September 01, 2022
Tweet

More Decks by Manfred Steyer

Other Decks in Programming

Transcript

  1. @ManfredSteyer @Component({ standalone: true, selector: 'app-root', imports: [ HomeComponent, AboutComponent,

    HttpClientModule, ], templateUrl: '…' }) export class AppComponent { […] }
  2. @ManfredSteyer export const APP_ROUTES: Routes = [ […], { path:

    'flight-booking', loadChildren: () => import('@nx-example/booking/feature-book') .then(m => m.FLIGHT_BOOKING_ROUTES) }, […] ];
  3. @ManfredSteyer export const APP_ROUTES: Routes = [ […], { path:

    'flight-booking', loadChildren: () => import('@nx-example/booking/feature-book') .then(m => m.FLIGHT_BOOKING_ROUTES) }, […] ];
  4. @ManfredSteyer export const APP_ROUTES: Routes = [ […], { path:

    'flight-booking', loadChildren: () => import('@nx-example/booking/feature-book') .then(m => m.FLIGHT_BOOKING_ROUTES) }, { path: 'next-flight', loadComponent: () => import('@nx-example/booking/feature-tickets') .then(m => m.NextFlightComponent) }, ];
  5. @ManfredSteyer export const FLIGHT_BOOKING_ROUTES: Routes = [{ path: '', component:

    FlightBookingComponent, providers: [ MyService ], children: [ […] ] }];
  6. @ManfredSteyer export const FLIGHT_BOOKING_ROUTES: Routes = [{ path: '', component:

    FlightBookingComponent, providers: [ MyService ], children: [ […] ] }]; Scope: This route + all child routes (Lazily) loaded with route config
  7. @ManfredSteyer export const FLIGHT_BOOKING_ROUTES: Routes = [{ path: '', component:

    FlightBookingComponent, providers: [ provideState(bookingFeature), provideEffects([BookingEffects]) ], children: [ […] ] }];
  8. @ManfredSteyer + Generates path mappings + Generates initial barrel +

    Prevents bypassing index.ts + Restricting access between libraries
  9. @ManfredSteyer provideRouter & withXYZ Directly point to lazy router configs

    Folders & Barrels Nx, Libs, and Constraints FTW!