SlideShare une entreprise Scribd logo
1  sur  96
Télécharger pour lire hors ligne
Angular ❤ CMS
a journey in dynamic content with @filipbech
@IMPACTdigitaldk
Filip
@filipbech
https://developers.google.com/experts/people/filip-bruun-bech-larsen
"
#weAreHiring #denmark #lisbon
https://www.facebook.com/groups/ngAarhus/
…enough about me
let’s talk about using Angular with a CMS!
Angular ❤ CMS
a journey in dynamic content with @filipbech
@IMPACTdigitaldk
Let’s do like angular 1
NOPE
need to bootstrap a component
…but we have no root
component?
Bootstrapping multiple
components
• 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)
Initial data and content
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?
Eeeewwwww
• even though it works - it feels terrible and wrong!
• and we need the parser at runtime
• so no AOT and bad perf
go see Pascals talk
tomorrow
still no animated 

page-transitions…
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…
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
**-route + generic
PageComponent
Get the data in a resolve
PageResolve is just a class with resolve(route)-method on it
In angularJS 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
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
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
What components
should be available?
we still can’t animate
page-transitions
cause its really not…
Custom RouterReuseStrategy
We have animations…
woohooooo
What about Rich-text
content from the CMS?
ng-bind-html
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
Server Side Rendering
SEO, social previews and 

faster perceived load-times
Seems 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)
Maintaining state
we want to maintain state, so we don’t re-do all fetches
and calculations when the client boots up
StateTransfer Service
@angular/platform-server
CACHING OF SSR
can’t work with personalisation
3 strategies
at client
bootstrap
at 1st user
interaction
no SSR
enter no-ssr directive
We made it to nirvana
Thank you, this was:
“Angular ❤ CMS”
I’m @filipbech
code: https://github.com/filipbech/ng-dynamic-spa
@IMPACTdigitaldk
Office hours at 13.45
Angular ❤️CMS

Contenu connexe

Tendances

The Thick Front-End
The Thick Front-EndThe Thick Front-End
The Thick Front-End
Jeff Dickey
 

Tendances (20)

Developing webapp using Polymer : is it ready for production? or not?
Developing webapp using Polymer : is it ready for production? or not?Developing webapp using Polymer : is it ready for production? or not?
Developing webapp using Polymer : is it ready for production? or not?
 
React-Native for multi-platform mobile applications @ Codemotion Rome 2017
React-Native for multi-platform mobile applications @ Codemotion Rome 2017React-Native for multi-platform mobile applications @ Codemotion Rome 2017
React-Native for multi-platform mobile applications @ Codemotion Rome 2017
 
Salvatore Laisa - Da Angular a React - Un viaggio inaspettato
Salvatore Laisa - Da Angular a React - Un viaggio inaspettatoSalvatore Laisa - Da Angular a React - Un viaggio inaspettato
Salvatore Laisa - Da Angular a React - Un viaggio inaspettato
 
The Thick Front-End
The Thick Front-EndThe Thick Front-End
The Thick Front-End
 
Getting Started with React Native (and should I use it at all?)
Getting Started with React Native (and should I use it at all?)Getting Started with React Native (and should I use it at all?)
Getting Started with React Native (and should I use it at all?)
 
Diving into SngularJS
Diving into SngularJSDiving into SngularJS
Diving into SngularJS
 
So you think you can scale
So you think you can scaleSo you think you can scale
So you think you can scale
 
Introduction to koyomi #appkoyomi
Introduction to koyomi #appkoyomiIntroduction to koyomi #appkoyomi
Introduction to koyomi #appkoyomi
 
FuelPHP
FuelPHPFuelPHP
FuelPHP
 
FuelPHP presentation - PeoplePerHour workshop
FuelPHP presentation - PeoplePerHour workshopFuelPHP presentation - PeoplePerHour workshop
FuelPHP presentation - PeoplePerHour workshop
 
Fast Web Applications with Go
Fast Web Applications with Go Fast Web Applications with Go
Fast Web Applications with Go
 
Say hello world with angular 5
Say hello world with angular 5Say hello world with angular 5
Say hello world with angular 5
 
Why use Go for web development?
Why use Go for web development?Why use Go for web development?
Why use Go for web development?
 
Back to the ng2 Future
Back to the ng2 FutureBack to the ng2 Future
Back to the ng2 Future
 
Blogging for hackers (english)
Blogging for hackers (english)Blogging for hackers (english)
Blogging for hackers (english)
 
EclipseCon-Europe 2013: Making the Eclipse IDE fun again
EclipseCon-Europe 2013: Making the Eclipse IDE fun againEclipseCon-Europe 2013: Making the Eclipse IDE fun again
EclipseCon-Europe 2013: Making the Eclipse IDE fun again
 
FuelPHP - a PHP HMVC Framework by silicongulf.com
FuelPHP - a PHP HMVC Framework by silicongulf.comFuelPHP - a PHP HMVC Framework by silicongulf.com
FuelPHP - a PHP HMVC Framework by silicongulf.com
 
Components vs Frameworks
Components vs FrameworksComponents vs Frameworks
Components vs Frameworks
 
A Gentle Introduction to GoOnRails
A Gentle Introduction to GoOnRailsA Gentle Introduction to GoOnRails
A Gentle Introduction to GoOnRails
 
Suggestatron
SuggestatronSuggestatron
Suggestatron
 

Similaire à Angular ❤️CMS

SharePoint Saturday Twin Cities - SharePoint Framework, Angular & Azure Funct...
SharePoint Saturday Twin Cities - SharePoint Framework, Angular & Azure Funct...SharePoint Saturday Twin Cities - SharePoint Framework, Angular & Azure Funct...
SharePoint Saturday Twin Cities - SharePoint Framework, Angular & Azure Funct...
Sébastien Levert
 
European Collaboration Summit - SharePoint Framework Angular & Azure Functions
European Collaboration Summit - SharePoint Framework Angular & Azure FunctionsEuropean Collaboration Summit - SharePoint Framework Angular & Azure Functions
European Collaboration Summit - SharePoint Framework Angular & Azure Functions
Sébastien Levert
 
North American Collaboration Summit 2018 - SharePoint Framework, Angular and ...
North American Collaboration Summit 2018 - SharePoint Framework, Angular and ...North American Collaboration Summit 2018 - SharePoint Framework, Angular and ...
North American Collaboration Summit 2018 - SharePoint Framework, Angular and ...
Sébastien Levert
 
North American Collaboration Summit 2018 - SharePoint Framework, Angular & Az...
North American Collaboration Summit 2018 - SharePoint Framework, Angular & Az...North American Collaboration Summit 2018 - SharePoint Framework, Angular & Az...
North American Collaboration Summit 2018 - SharePoint Framework, Angular & Az...
Sébastien Levert
 
European SharePoint Conference 2017 - SharePoint Framework, Angular & Azure F...
European SharePoint Conference 2017 - SharePoint Framework, Angular & Azure F...European SharePoint Conference 2017 - SharePoint Framework, Angular & Azure F...
European SharePoint Conference 2017 - SharePoint Framework, Angular & Azure F...
Sébastien Levert
 
Future proofing design work with Web components
Future proofing design work with Web componentsFuture proofing design work with Web components
Future proofing design work with Web components
btopro
 

Similaire à Angular ❤️CMS (20)

Building a dynamic SPA website with Angular
Building a dynamic SPA website with AngularBuilding a dynamic SPA website with Angular
Building a dynamic SPA website with Angular
 
SharePoint Saturday Twin Cities - SharePoint Framework, Angular & Azure Funct...
SharePoint Saturday Twin Cities - SharePoint Framework, Angular & Azure Funct...SharePoint Saturday Twin Cities - SharePoint Framework, Angular & Azure Funct...
SharePoint Saturday Twin Cities - SharePoint Framework, Angular & Azure Funct...
 
The future of templating and frameworks
The future of templating and frameworksThe future of templating and frameworks
The future of templating and frameworks
 
Whats next in templating
Whats next in templatingWhats next in templating
Whats next in templating
 
Whats next in templating
Whats next in templatingWhats next in templating
Whats next in templating
 
European Collaboration Summit - SharePoint Framework Angular & Azure Functions
European Collaboration Summit - SharePoint Framework Angular & Azure FunctionsEuropean Collaboration Summit - SharePoint Framework Angular & Azure Functions
European Collaboration Summit - SharePoint Framework Angular & Azure Functions
 
North American Collaboration Summit 2018 - SharePoint Framework, Angular and ...
North American Collaboration Summit 2018 - SharePoint Framework, Angular and ...North American Collaboration Summit 2018 - SharePoint Framework, Angular and ...
North American Collaboration Summit 2018 - SharePoint Framework, Angular and ...
 
North American Collaboration Summit 2018 - SharePoint Framework, Angular & Az...
North American Collaboration Summit 2018 - SharePoint Framework, Angular & Az...North American Collaboration Summit 2018 - SharePoint Framework, Angular & Az...
North American Collaboration Summit 2018 - SharePoint Framework, Angular & Az...
 
European SharePoint Conference 2017 - SharePoint Framework, Angular & Azure F...
European SharePoint Conference 2017 - SharePoint Framework, Angular & Azure F...European SharePoint Conference 2017 - SharePoint Framework, Angular & Azure F...
European SharePoint Conference 2017 - SharePoint Framework, Angular & Azure F...
 
Open Apereo - Web components workshop
Open Apereo - Web components workshopOpen Apereo - Web components workshop
Open Apereo - Web components workshop
 
Angular 1.x reloaded: improve your app now! and get ready for 2.0
Angular 1.x reloaded:  improve your app now! and get ready for 2.0Angular 1.x reloaded:  improve your app now! and get ready for 2.0
Angular 1.x reloaded: improve your app now! and get ready for 2.0
 
Prototype4Production Presented at FOSSASIA2015 at Singapore
Prototype4Production Presented at FOSSASIA2015 at SingaporePrototype4Production Presented at FOSSASIA2015 at Singapore
Prototype4Production Presented at FOSSASIA2015 at Singapore
 
Joomla X Overview
Joomla X OverviewJoomla X Overview
Joomla X Overview
 
Future proofing design work with Web components
Future proofing design work with Web componentsFuture proofing design work with Web components
Future proofing design work with Web components
 
GWT Architectures and Lessons Learned (WJAX 2013)
GWT Architectures and Lessons Learned (WJAX 2013)GWT Architectures and Lessons Learned (WJAX 2013)
GWT Architectures and Lessons Learned (WJAX 2013)
 
Angular 2 - How we got here?
Angular 2 - How we got here?Angular 2 - How we got here?
Angular 2 - How we got here?
 
Building a blog with an Onion Architecture
Building a blog with an Onion ArchitectureBuilding a blog with an Onion Architecture
Building a blog with an Onion Architecture
 
Onion Architecture and the Blog
Onion Architecture and the BlogOnion Architecture and the Blog
Onion Architecture and the Blog
 
Desktop apps with node webkit
Desktop apps with node webkitDesktop apps with node webkit
Desktop apps with node webkit
 
Professionalizing the Front-end
Professionalizing the Front-endProfessionalizing the Front-end
Professionalizing the Front-end
 

Plus de Filip Bruun Bech-Larsen

Plus de Filip Bruun Bech-Larsen (20)

Webcomponents from 0-100 - with Google's Lit
Webcomponents from 0-100 - with Google's LitWebcomponents from 0-100 - with Google's Lit
Webcomponents from 0-100 - with Google's Lit
 
Webcomponents are your frameworks best friend
Webcomponents are your frameworks best friendWebcomponents are your frameworks best friend
Webcomponents are your frameworks best friend
 
Content as a Service with Umbraco Headless
Content as a Service with Umbraco HeadlessContent as a Service with Umbraco Headless
Content as a Service with Umbraco Headless
 
Frameworks and webcomponents
Frameworks and webcomponentsFrameworks and webcomponents
Frameworks and webcomponents
 
Whats next in clientside templating
Whats next in clientside templatingWhats next in clientside templating
Whats next in clientside templating
 
Whats next in clientside templating
Whats next in clientside templatingWhats next in clientside templating
Whats next in clientside templating
 
Future of the Web
Future of the WebFuture of the Web
Future of the Web
 
Diversity at impact
Diversity at impactDiversity at impact
Diversity at impact
 
The Future of the web
The Future of the webThe Future of the web
The Future of the web
 
Frontend development of the (current) future
Frontend development of the (current) futureFrontend development of the (current) future
Frontend development of the (current) future
 
Commerce and the browser in 2017
Commerce and the browser in 2017Commerce and the browser in 2017
Commerce and the browser in 2017
 
Frontend State of the union
Frontend State of the unionFrontend State of the union
Frontend State of the union
 
AngularJS best practices
AngularJS best practicesAngularJS best practices
AngularJS best practices
 
Frontend development of the (current) future
Frontend development of the (current) futureFrontend development of the (current) future
Frontend development of the (current) future
 
Observables - the why, what & how
Observables - the why, what & howObservables - the why, what & how
Observables - the why, what & how
 
Angular2 workshop
Angular2 workshopAngular2 workshop
Angular2 workshop
 
Progressive Web Apps og Payment Request
Progressive Web Apps og Payment RequestProgressive Web Apps og Payment Request
Progressive Web Apps og Payment Request
 
Spangulumbraco
SpangulumbracoSpangulumbraco
Spangulumbraco
 
Web development post io2016
Web development post io2016Web development post io2016
Web development post io2016
 
Observables in angular2
Observables in angular2Observables in angular2
Observables in angular2
 

Dernier

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Dernier (20)

Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 

Angular ❤️CMS