Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Routing into the Sunset with Angular
Search
Manfred Steyer
PRO
October 24, 2017
Programming
1
240
Routing into the Sunset with Angular
Talk from International JavaScript Conference in Munich, October 2017
Manfred Steyer
PRO
October 24, 2017
Tweet
Share
More Decks by Manfred Steyer
See All by Manfred Steyer
Rethinking Angular: The Future with Signals and the New Resource API @iJS Munich 2025
manfredsteyer
PRO
0
52
Reactivity, Reimagined: Angular Signals at Every Layer
manfredsteyer
PRO
0
59
Angular Architecture Workshop @AngularDays in Berlin 2025
manfredsteyer
PRO
0
57
Migration to Signals, Resource API, and NgRx Signal Store
manfredsteyer
PRO
0
130
Reactive Thinking with Signals and the Resource API
manfredsteyer
PRO
0
120
All About Angular's New Signal Forms
manfredsteyer
PRO
0
220
Your Perfect Project Setup for Angular @BASTA! 2025 in Mainz
manfredsteyer
PRO
0
230
Signals & Resource API in Angular: 3 Effective Rules for Your Architecture @BASTA 2025 in Mainz
manfredsteyer
PRO
0
150
Your Architecture as a Crime SceneForensic Analysis @BASTA! 2025 in Mainz, Germany
manfredsteyer
PRO
0
83
Other Decks in Programming
See All in Programming
data-viz-talk-cz-2025
lcolladotor
0
100
Pythonに漸進的に型をつける
nealle
1
140
テーブル定義書の構造化抽出して、生成AIでDWH分析を試してみた / devio2025tokyo
kasacchiful
0
340
Node-REDのノードの開発・活用事例とコミュニティとの関わり(Node-RED Con Nagoya 2025)
404background
0
100
Claude Agent SDK を使ってみよう
hyshu
0
1.4k
CSC305 Lecture 11
javiergs
PRO
0
310
TransformerからMCPまで(現代AIを理解するための羅針盤)
mickey_kubo
7
5.7k
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
400
Vue 3.6 時代のリアクティビティ最前線 〜Vapor/alien-signals の実践とパフォーマンス最適化〜
hiranuma
2
280
What Spring Developers Should Know About Jakarta EE
ivargrimstad
0
600
Using Types to Save Your Code's Future
rollbear
0
100
SODA - FACT BOOK(JP)
sodainc
1
8.9k
Featured
See All Featured
Testing 201, or: Great Expectations
jmmastey
45
7.7k
Mobile First: as difficult as doing things right
swwweet
225
10k
BBQ
matthewcrist
89
9.9k
How to Ace a Technical Interview
jacobian
280
24k
Learning to Love Humans: Emotional Interface Design
aarron
274
41k
How GitHub (no longer) Works
holman
315
140k
Faster Mobile Websites
deanohume
310
31k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
16k
Balancing Empowerment & Direction
lara
5
710
How STYLIGHT went responsive
nonsquared
100
5.9k
What's in a price? How to price your products and services
michaelherold
246
12k
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
Transcript
Routing into the Sunset with Angular Manfred Steyer ManfredSteyer
About me… • Manfred Steyer • SOFTWAREarchitekt.at • Trainer &
Consultant • Focus: Angular • Google Developer Expert (GDE) Page ▪ 2 Manfred Steyer
Contents • Basics • Child Routes • Aux Routes •
Guards • Lazy Loading
Angular Router Page ▪ 4
Routing in Angular Page ▪ 5 Logo + Menu Menu
2 Footer SPA Placeholder
Routing in Angular Page ▪ 6 Logo + Menu Menu
2 Footer SPA Passenger- Component /FlightApp/passenger
Configuration Page ▪ 7 const APP_ROUTES: Routes = [ {
path: 'home', component: HomeComponent }, { path: 'flight-search', component: FlightSearchComponent }, { path: '**', redirectTo: 'home' } ]
Configuration Page ▪ 8 // app.module.ts @NgModule({ imports: [ BrowserModule,
HttpModule, FormsModule, RouterModule.forRoot(ROUTE_CONFIG) ], […] }) export class AppModule { } For Root-Module For Feature-Module: forChild
AppComponent Page ▪ 9 <a routerLink="/home">Home</a> <a routerLink="/flight-search">Flight Search</a> <div>
<router-outlet></router-outlet> </div>
Parameters • passagier/7 • passagier/7?details=true&page=7 • passagier/7;details=true;page=7 • passagier/7;details=true;page=7/fluege Page
▪ 10
Parameters Page ▪ 11 const APP_ROUTES: Routes = [ […]
{ path: 'flight-search', component: FlightSearchComponent }, { path: 'flight-edit/:id', component: FlightEditComponent } }
Reading Parameters Page ▪ 12 export class FlightEditComponent { public
id: string; constructor( private route: ActivatedRoute) { route.params.subscribe( p => { this.id = p['id']; […] } ); } […] }
Links for Routen with Parameters Page ▪ 13 <a [routerLink]="['/flight-edit',
flug.id, {showDetails: true}]">Edit</a>
Hierarchical Routing Page ▪ 14
Hierarchical Routing Page ▪ 15 Logo + Menu Menu 2
Footer SPA Placeholder 1
Hierarchical Routing Page ▪ 16 Logo + Menu Menu 2
Footer SPA /FlightDemo/flight-booking FlightBookingComponent
Hierarchical Routing Page ▪ 17 Logo + Menu Menu 2
Footer SPA Options Placeholder FlightBookingComponent /FlightDemo/flight-booking
Hierarchical Routing Page ▪ 18 Logo + Menu Menu 2
Footer SPA Optionen Passenger Component FlightBookingComponent /FlightDemo/flight-booking/passenger
Configuration Page ▪ 19 const APP_ROUTES: Routes = [ {
path: '', component: HomeComponent }, { path: 'flight-booking', component: FlightBookingComponent, children: [ { path: 'flight-search', component: FlightSearchComponent }, […] ] } ];
DEMO Page ▪ 20 App Home Flight Booking Flight Search
Flight Edit Passenger Search Other Stuff
Aux Routes
Aux-Routes Page ▪ 22 Logo + Menu Menu 2 Footer
SPA Placeholder Named Placeholder
Aux-Routes Page ▪ 23 Logo + Menu Menu 2 Footer
SPA Flight- Component Named Placeholder /FlightApp/flights
Aux-Routes Page ▪ 24 Logo + Menu Menu 2 Footer
SPA Flight- Component Info-Component /FlightApp/flights(aux:info)
Aux-Routes Page ▪ 25 Logo + Menu Menu 2 Footer
SPA Flight- Component Modal-Component /FlightApp/flights(aux:info/modal)
Aux-Routes Page ▪ 26 Logo + Menu Menu 2 Footer
SPA Flight-Edit- Component Modal-Component /FlightApp/flights(aux:info/modal)/edit/17
Use Cases • Partly autonomous parts of an application •
„Norton Commander Style“ • (CSS-based) Popups and Modals
DEMO Page ▪ 28
Guards Page ▪ 29
What are Guard? • Services • Can prevent the Activation
or Deactivation of a Route Page ▪ 30
Guards Result: boolean | Observable<boolean> | Promise<boolean> CanActivate canActivate CanActivateChild
canActivateChild CanLoad canLoad CanDeactivate<T> canDeactivate
Guards in der Konfiguration Page ▪ 33 const APP_ROUTES: Routes
= [ { path: '/flight-booking', component: FlightBookingComponent, canActivate: [AuthGuard], children: [ { path: 'flight-edit/:id', component: FlightEditComponent, canDeactivate: [FlightEditGuard] }, […] ] ] Token
Provider für Guards Page ▪ 35 // app.module.ts @NgModule({ providers:
[ FlightEditGuard, AuthGuard ], […] }) export class AppModule { }
DEMO Page ▪ 36
Lazy Loading
Root Module with Lazy Loading Page ▪ 45 const APP_ROUTE_CONFIG:
Routes = [ { path: 'home', component: HomeComponent }, { path: 'flights', loadChildren: './[…]flight-booking.module#FlightBookingModule' } ];
Routes for Feature Module Page ▪ 46 const FLIGHT_ROUTES =
[ { path: '/bookings', component: FlightBookingComponent, […] }, […] } Url: /flights/bookings Triggers Lazy Loading
Preloading
Idea • Modules that might be needed later are loaded
after (!) the start of the application • When the module is actually needed, it is available immediately Page ▪ 49
Activating Preloading Page ▪ 50 const AppRoutesModule = RouterModule.forRoot( ROUTE_CONFIG,
{ preloadingStrategy: PreloadAllModules });
Lazy Loading and Shared Modules Page ▪ 51
DEMO Page ▪ 52
Lazy Loading and Shared Modules Page ▪ 53 AppModule FlightModule
SharedModule includes includes (lazy) includes AuthService
Lazy Loading and Shared Modules Page ▪ 54 AppModule FlightModule
SharedModule includes includes (lazy) includes AuthService AuthService
Lazy Loading and Shared Modules Page ▪ 55 AppModule FlightModule
SharedModule includes includes (lazy) includes AuthService AuthService
Solution Page ▪ 56 AppModule FlightModule SharedModule includes (lazy) includes
CoreModule includes includes Only import CoreModule into AppModule! Global Providers like AuthService & Shell
DEMO
Huge CoreModule? Page ▪ 58 AppModule FlightModule SharedModule includes (lazy)
includes CoreModule includes includes
Solution Page ▪ 59 AppModule FlightModule AuthModule includes (lazy) CoreModule
Solution Page ▪ 60 AppModule FlightModule AuthModule includes (lazy) includes
(with Services) CoreModule includes includes (without Services)
Auth Module Page ▪ 61 @NgModule({ […], providers: [] })
export class AuthModule { }
Auth Module Page ▪ 62 @NgModule({ […], providers: [] })
export class AuthModule { static forRoot(): ModuleWithProviders { return { ngModule: AuthModule, providers: [AuthService, […]] } } }
DEMO Page ▪ 63
Conclusion Child Routes Aux Routes Guards Lazy Loading
Downloads and Contact [mail]
[email protected]
[blog] SOFTWAREarchitekt.at [twitter] ManfredSteyer