SlideShare a Scribd company logo
Building a dynamic SPA
a journey with @filipbech
@IMPACTdigitaldk
Filip
@filipbech
!
#weAreHiring #denmark
https://www.facebook.com/groups/ngAarhus/
https://developers.google.com/experts/people/filip-bruun-bech-larsen
…enough about me
let’s use Angular for dynamic content
Building a dynamic SPA
a journey with @filipbech
@IMPACTdigitaldk
or “How to use Angular
with your cms”
Let’s do like angular 1
NOPE
need to bootstrap a component
Building a dynamic SPA website with Angular
…but we have no root app?
• multiple entrypoints
Bootstrapping multiple
applications
• its a little harder to maintain state between applications
(but possible)
• the cms now needs to know what components are
angular-components, so they can all be bootstrapped.
(and their DOM-nodes if multiple of the same
component)
Building a dynamic SPA website with Angular
Initial data
• We need to feed data (settings, initial data) into some of
the components (from the cms), and put content inside
them.
Building a dynamic SPA website with Angular
NOPE
Because
• Root-components cannot have inputs
• Root-components cannot use content-projection
(transclusion)
https://github.com/angular/angular/issues/1858
How about a <body>-
component then?
Building a dynamic SPA website with Angular
Eeeewwwww
• even though it works - it feels terrible and wrong!
• and we need the parser at runtime
• so no AOT and bad perf
We need a SPA
Single Page Application
• so we can also share state between routes
• animate route-changes
• and much more…
Demo-time
to heighten the suspense…
Building a dynamic SPA website with Angular
It starts with a router
…thats not very dynamic
We have too many routes with
no patterns
• “/“ is a frontpage
• “/om/os” is a content-page
• “/mejeri“ is a category-page
• “/mejeri/ost“ is a sub-category-page
• “/ost-i-skiver-mild-13-cheasy-200-g” is a product-page
So I talked to the Angular team…
…let the CMS
output route-config
Two issues with that approach
• Need to build and invalidate the bundle’s cache every
time an editor makes a change
• Users get stuck on the route-config they get at first load
One route to rule them all
Building a dynamic SPA website with Angular
**-route + generic
PageComponent
Get the data in a resolve
PageResolve is just a class with resolve(route)-method on it
In angular 1.x we could use templateFactory and
select a template based on the api-response
But we cannot do that in Angular 2+, because 

there is no template-parser at runtime
All possible
PageComponents with
individual *ngIf’s
Building a dynamic SPA website with Angular
Eeeewwwww
Even though all the *ngIfs in the template are AOT
compiled into something more acceptable…
It still seems wrong to have it in the template!
but (for now) it works…
until you navigate around

(nothing happens)
you’re not changing the route
just its options
(so: no new resolve, no new ngOnInit)
Refactoring
• Listen for route-changes and handle resolving data
manually
Building a dynamic SPA website with Angular
The problem cascades
• When we go from one product-detail-page to another
product-detail-page…
• Refactor init-logic into ngOnChanges
Then came rc4
ComponentFactoryResolver adds beauty
and power to generic components…
The theory
Building a dynamic SPA website with Angular
What components
should be available?
Building a dynamic SPA website with Angular
We need a routeChange
for animations
and it would feel a lot better too
Custom RouterReuseStrategy
Building a dynamic SPA website with Angular
Building a dynamic SPA website with Angular
What about Rich-text
content from the CMS?
Building a dynamic SPA website with Angular
Building a dynamic SPA website with Angular
ng-bind-html
Building a dynamic SPA website with Angular
Perfect, except for links
the router doesn’t “hijack”
a[href]-clicks like uiRouter
enter the [href] directive
NOPE
@Hostlistener =>
router.go()
* in reality it’s a little more complicated
Sweeeet
all we ever wanted
Without all the ugly
Flexibility
real routes => getting data in resolve + animations
Rich Text
Same approach for the
dynamic content spots
* we add another directive so we can repeat via *ngForOf
AOT
#justWorks
Building a dynamic SPA website with Angular
Add PageComponents to
ngModule entryComponents
Faster and lighter
Initial parse goes from 450ms to 250ms
Without AOT
With AOT
Server Side Rendering
SEO, social previews and 

faster perceived load-times
Angular Universal is so hot right now…(in core)
Hard to wrap your head
around universal
The idea
• server.module and a client.module
• they both import the app.module
• server and client module then replaces the
dependencies that are different with appropriate
environment-versions (eg. xhr or node-fetch, DOM or
virtual-dom)
Can’t touch this (the DOM)
(no direct window, querySelector, localstorage)
Building a dynamic SPA website with Angular
Building a dynamic SPA website with Angular
Maintaining state
we want to maintain state, so we don’t re-do all fetches
and calculations when the client boots up
StateTransfer Service
holds data
+ hooks for dehydrate/rehydrate via json
* idea credit to the universal creators…
Building a dynamic SPA website with Angular
Building a dynamic SPA website with Angular
Building a dynamic SPA website with Angular
Building a dynamic SPA website with Angular
CACHING OF SSR
can’t work with personalisation
3 strategies
at Launch
at user
interaction
just don’t
enter no-ssr directive
Building a dynamic SPA website with Angular
Building a dynamic SPA website with Angular
We made it to nirvana
Thank you, this was:
“building a dynamic SPA with Angular”
I’m @filipbech
code: https://github.com/filipbech/ng-dynamic-spa
@IMPACTdigitaldk
Building a dynamic SPA website with Angular

More Related Content

PDF
Angular ❤️CMS
Filip Bruun Bech-Larsen
 
PDF
Angular ❤️ CMS from #AngularUp
Filip Bruun Bech-Larsen
 
PPTX
Dynamic content with Angular
Filip Bruun Bech-Larsen
 
PPTX
European Collaboration Summit - SharePoint Framework Angular & Azure Functions
Sébastien Levert
 
PDF
BP101: A Modernized Workflow w/ Domino/XPages
edm00se
 
PDF
Introduction To Single Page Application
KMS Technology
 
PPTX
SharePoint Saturday Twin Cities - SharePoint Framework, Angular & Azure Funct...
Sébastien Levert
 
PDF
Client Vs. Server Rendering
David Amend
 
Angular ❤️CMS
Filip Bruun Bech-Larsen
 
Angular ❤️ CMS from #AngularUp
Filip Bruun Bech-Larsen
 
Dynamic content with Angular
Filip Bruun Bech-Larsen
 
European Collaboration Summit - SharePoint Framework Angular & Azure Functions
Sébastien Levert
 
BP101: A Modernized Workflow w/ Domino/XPages
edm00se
 
Introduction To Single Page Application
KMS Technology
 
SharePoint Saturday Twin Cities - SharePoint Framework, Angular & Azure Funct...
Sébastien Levert
 
Client Vs. Server Rendering
David Amend
 

What's hot (20)

PPTX
Lightweight webdev
damianofusco
 
PDF
Isomorphic web application
Oliver N
 
PPTX
SharePoint Saturday Vancouver - SharePoint Framework, Angular and Azure Funct...
Sébastien Levert
 
PPTX
SharePoint Fest DC - SharePoint Framework, Angular and Azure Functions
Sébastien Levert
 
PDF
React server side rendering performance
Nick Dreckshage
 
PPTX
Rise of the responsive single page application
Oren Shatken
 
PPTX
North American Collaboration Summit 2018 - SharePoint Framework, Angular & Az...
Sébastien Levert
 
PDF
Angular 2 vs React
Iran Reyes Fleitas
 
PPTX
Angular.js in XPages
Mark Roden
 
PDF
Getting Started with the Angular 2 CLI
Jim Lynch
 
PDF
Server rendering-talk
Daiwei Lu
 
PDF
Contentful with Netgen Layouts workshop
Ivo Lukac
 
PDF
Website building exercise
meilai521
 
PPTX
Advanced AngularJS Tips and Tricks
Jeremy Likness
 
PDF
Developing webapp using Polymer : is it ready for production? or not?
Jeongkyu Shin
 
PDF
The Dark Side of Single Page Applications
Dor Kalev
 
PDF
Introduction to React Native
Polidea
 
PDF
Client vs Server Templating: Speed up initial load for SPA with Angular as an...
David Amend
 
PPTX
Isomorphic JavaScript – future of the web
Sigma Software
 
PDF
RailsAdmin - Overview and Best practices
Benoit Bénézech
 
Lightweight webdev
damianofusco
 
Isomorphic web application
Oliver N
 
SharePoint Saturday Vancouver - SharePoint Framework, Angular and Azure Funct...
Sébastien Levert
 
SharePoint Fest DC - SharePoint Framework, Angular and Azure Functions
Sébastien Levert
 
React server side rendering performance
Nick Dreckshage
 
Rise of the responsive single page application
Oren Shatken
 
North American Collaboration Summit 2018 - SharePoint Framework, Angular & Az...
Sébastien Levert
 
Angular 2 vs React
Iran Reyes Fleitas
 
Angular.js in XPages
Mark Roden
 
Getting Started with the Angular 2 CLI
Jim Lynch
 
Server rendering-talk
Daiwei Lu
 
Contentful with Netgen Layouts workshop
Ivo Lukac
 
Website building exercise
meilai521
 
Advanced AngularJS Tips and Tricks
Jeremy Likness
 
Developing webapp using Polymer : is it ready for production? or not?
Jeongkyu Shin
 
The Dark Side of Single Page Applications
Dor Kalev
 
Introduction to React Native
Polidea
 
Client vs Server Templating: Speed up initial load for SPA with Angular as an...
David Amend
 
Isomorphic JavaScript – future of the web
Sigma Software
 
RailsAdmin - Overview and Best practices
Benoit Bénézech
 
Ad

Similar to Building a dynamic SPA website with Angular (20)

PDF
Whats next in templating
Filip Bruun Bech-Larsen
 
PDF
The future of templating and frameworks
Filip Bruun Bech-Larsen
 
PDF
Aurelia intro
Ats Uiboupin
 
PDF
Whats next in templating
Filip Bruun Bech-Larsen
 
PPTX
SharePoint Fest Chicago 2017 - SharePoint Framework, Angular & Azure Functions
Sébastien Levert
 
PPTX
Angular js workshop
Rolands Krumbergs
 
PPTX
SharePoint Saturday Utah 2018 - SharePoint Framework, Angular and Azure Funct...
Sébastien Levert
 
PDF
End to end testing Single Page Apps & APIs with Cucumber.js and Puppeteer (Em...
Paul Jensen
 
PDF
Angular - Chapter 3 - Components
WebStackAcademy
 
PDF
Integrating Social Apps with Content Driven Sites using Apache Rave and Sprin...
ate.douma
 
PPTX
SharePoint Framework, Angular and Azure Functions
Sébastien Levert
 
PPTX
Angular 6 Training with project in hyderabad india
php2ranjan
 
PPTX
Expo Router V2
😎 Anthony Kariuki
 
PPTX
European SharePoint Conference 2017 - SharePoint Framework, Angular & Azure F...
Sébastien Levert
 
PDF
Implement lazy loading in your existing angular application (get a faster, be...
Katy Slemon
 
PDF
Strategies and Tips for Building Enterprise Drupal Applications - PNWDS 2013
Mack Hardy
 
PPTX
SharePoint Saturday Lisbon 2017 - SharePoint Framework, Angular & Azure Funct...
Sébastien Levert
 
PPTX
Umbraco Cape Town Meetup Presentation
Bluegrass Digital
 
PPTX
Web worker in your angular application
Suresh Patidar
 
PDF
Step by Step Guide on Lazy Loading in Angular 11
Katy Slemon
 
Whats next in templating
Filip Bruun Bech-Larsen
 
The future of templating and frameworks
Filip Bruun Bech-Larsen
 
Aurelia intro
Ats Uiboupin
 
Whats next in templating
Filip Bruun Bech-Larsen
 
SharePoint Fest Chicago 2017 - SharePoint Framework, Angular & Azure Functions
Sébastien Levert
 
Angular js workshop
Rolands Krumbergs
 
SharePoint Saturday Utah 2018 - SharePoint Framework, Angular and Azure Funct...
Sébastien Levert
 
End to end testing Single Page Apps & APIs with Cucumber.js and Puppeteer (Em...
Paul Jensen
 
Angular - Chapter 3 - Components
WebStackAcademy
 
Integrating Social Apps with Content Driven Sites using Apache Rave and Sprin...
ate.douma
 
SharePoint Framework, Angular and Azure Functions
Sébastien Levert
 
Angular 6 Training with project in hyderabad india
php2ranjan
 
Expo Router V2
😎 Anthony Kariuki
 
European SharePoint Conference 2017 - SharePoint Framework, Angular & Azure F...
Sébastien Levert
 
Implement lazy loading in your existing angular application (get a faster, be...
Katy Slemon
 
Strategies and Tips for Building Enterprise Drupal Applications - PNWDS 2013
Mack Hardy
 
SharePoint Saturday Lisbon 2017 - SharePoint Framework, Angular & Azure Funct...
Sébastien Levert
 
Umbraco Cape Town Meetup Presentation
Bluegrass Digital
 
Web worker in your angular application
Suresh Patidar
 
Step by Step Guide on Lazy Loading in Angular 11
Katy Slemon
 
Ad

More from Filip Bruun Bech-Larsen (20)

PDF
Webcomponents from 0-100 - with Google's Lit
Filip Bruun Bech-Larsen
 
PDF
Webcomponents are your frameworks best friend
Filip Bruun Bech-Larsen
 
PDF
Content as a Service with Umbraco Headless
Filip Bruun Bech-Larsen
 
PDF
Frameworks and webcomponents
Filip Bruun Bech-Larsen
 
PDF
Whats next in clientside templating
Filip Bruun Bech-Larsen
 
PDF
Whats next in clientside templating
Filip Bruun Bech-Larsen
 
PDF
Future of the Web
Filip Bruun Bech-Larsen
 
PDF
Diversity at impact
Filip Bruun Bech-Larsen
 
PDF
The Future of the web
Filip Bruun Bech-Larsen
 
PDF
Frontend development of the (current) future
Filip Bruun Bech-Larsen
 
PDF
Commerce and the browser in 2017
Filip Bruun Bech-Larsen
 
PPTX
Frontend State of the union
Filip Bruun Bech-Larsen
 
PPTX
AngularJS best practices
Filip Bruun Bech-Larsen
 
PPTX
Frontend development of the (current) future
Filip Bruun Bech-Larsen
 
PPTX
Observables - the why, what & how
Filip Bruun Bech-Larsen
 
PPTX
Angular2 workshop
Filip Bruun Bech-Larsen
 
PPTX
Progressive Web Apps og Payment Request
Filip Bruun Bech-Larsen
 
PPTX
Spangulumbraco
Filip Bruun Bech-Larsen
 
PPTX
Web development post io2016
Filip Bruun Bech-Larsen
 
PPTX
Observables in angular2
Filip Bruun Bech-Larsen
 
Webcomponents from 0-100 - with Google's Lit
Filip Bruun Bech-Larsen
 
Webcomponents are your frameworks best friend
Filip Bruun Bech-Larsen
 
Content as a Service with Umbraco Headless
Filip Bruun Bech-Larsen
 
Frameworks and webcomponents
Filip Bruun Bech-Larsen
 
Whats next in clientside templating
Filip Bruun Bech-Larsen
 
Whats next in clientside templating
Filip Bruun Bech-Larsen
 
Future of the Web
Filip Bruun Bech-Larsen
 
Diversity at impact
Filip Bruun Bech-Larsen
 
The Future of the web
Filip Bruun Bech-Larsen
 
Frontend development of the (current) future
Filip Bruun Bech-Larsen
 
Commerce and the browser in 2017
Filip Bruun Bech-Larsen
 
Frontend State of the union
Filip Bruun Bech-Larsen
 
AngularJS best practices
Filip Bruun Bech-Larsen
 
Frontend development of the (current) future
Filip Bruun Bech-Larsen
 
Observables - the why, what & how
Filip Bruun Bech-Larsen
 
Angular2 workshop
Filip Bruun Bech-Larsen
 
Progressive Web Apps og Payment Request
Filip Bruun Bech-Larsen
 
Spangulumbraco
Filip Bruun Bech-Larsen
 
Web development post io2016
Filip Bruun Bech-Larsen
 
Observables in angular2
Filip Bruun Bech-Larsen
 

Recently uploaded (20)

PDF
Make GenAI investments go further with the Dell AI Factory - Infographic
Principled Technologies
 
PDF
DevOps & Developer Experience Summer BBQ
AUGNYC
 
PDF
CIFDAQ's Teaching Thursday: Moving Averages Made Simple
CIFDAQ
 
PDF
agentic-ai-and-the-future-of-autonomous-systems.pdf
siddharthnetsavvies
 
PDF
Cloud-Migration-Best-Practices-A-Practical-Guide-to-AWS-Azure-and-Google-Clou...
Artjoker Software Development Company
 
PDF
Building High-Performance Oracle Teams: Strategic Staffing for Database Manag...
SMACT Works
 
PDF
How-Cloud-Computing-Impacts-Businesses-in-2025-and-Beyond.pdf
Artjoker Software Development Company
 
PDF
REPORT: Heating appliances market in Poland 2024
SPIUG
 
PPTX
Smart Infrastructure and Automation through IoT Sensors
Rejig Digital
 
PDF
BLW VOCATIONAL TRAINING SUMMER INTERNSHIP REPORT
codernjn73
 
PDF
Software Development Methodologies in 2025
KodekX
 
PDF
Chapter 2 Digital Image Fundamentals.pdf
Getnet Tigabie Askale -(GM)
 
PDF
Event Presentation Google Cloud Next Extended 2025
minhtrietgect
 
PPTX
AI and Robotics for Human Well-being.pptx
JAYMIN SUTHAR
 
PDF
Revolutionize Operations with Intelligent IoT Monitoring and Control
Rejig Digital
 
PDF
Orbitly Pitch Deck|A Mission-Driven Platform for Side Project Collaboration (...
zz41354899
 
PDF
Security features in Dell, HP, and Lenovo PC systems: A research-based compar...
Principled Technologies
 
PDF
Presentation about Hardware and Software in Computer
snehamodhawadiya
 
PDF
Enable Enterprise-Ready Security on IBM i Systems.pdf
Precisely
 
PPTX
How to Build a Scalable Micro-Investing Platform in 2025 - A Founder’s Guide ...
Third Rock Techkno
 
Make GenAI investments go further with the Dell AI Factory - Infographic
Principled Technologies
 
DevOps & Developer Experience Summer BBQ
AUGNYC
 
CIFDAQ's Teaching Thursday: Moving Averages Made Simple
CIFDAQ
 
agentic-ai-and-the-future-of-autonomous-systems.pdf
siddharthnetsavvies
 
Cloud-Migration-Best-Practices-A-Practical-Guide-to-AWS-Azure-and-Google-Clou...
Artjoker Software Development Company
 
Building High-Performance Oracle Teams: Strategic Staffing for Database Manag...
SMACT Works
 
How-Cloud-Computing-Impacts-Businesses-in-2025-and-Beyond.pdf
Artjoker Software Development Company
 
REPORT: Heating appliances market in Poland 2024
SPIUG
 
Smart Infrastructure and Automation through IoT Sensors
Rejig Digital
 
BLW VOCATIONAL TRAINING SUMMER INTERNSHIP REPORT
codernjn73
 
Software Development Methodologies in 2025
KodekX
 
Chapter 2 Digital Image Fundamentals.pdf
Getnet Tigabie Askale -(GM)
 
Event Presentation Google Cloud Next Extended 2025
minhtrietgect
 
AI and Robotics for Human Well-being.pptx
JAYMIN SUTHAR
 
Revolutionize Operations with Intelligent IoT Monitoring and Control
Rejig Digital
 
Orbitly Pitch Deck|A Mission-Driven Platform for Side Project Collaboration (...
zz41354899
 
Security features in Dell, HP, and Lenovo PC systems: A research-based compar...
Principled Technologies
 
Presentation about Hardware and Software in Computer
snehamodhawadiya
 
Enable Enterprise-Ready Security on IBM i Systems.pdf
Precisely
 
How to Build a Scalable Micro-Investing Platform in 2025 - A Founder’s Guide ...
Third Rock Techkno
 

Building a dynamic SPA website with Angular