Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Web Components with Angular: Workshop @MobileTe...
Search
Manfred Steyer
PRO
March 25, 2019
Programming
380
3
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Web Components with Angular: Workshop @MobileTechCon Munich 2019
Examples:
https://github.com/manfredsteyer/web-components
Manfred Steyer
PRO
March 25, 2019
More Decks by Manfred Steyer
See All by Manfred Steyer
Human in the Loop Beyond Approval: Toward True Collaboration @FrontMania 2026 in Utrecht
manfredsteyer
PRO
0
55
Agentic UI: Where the Agent meets the User @FrontMania 2026 in Utrecht
manfredsteyer
PRO
0
50
A2UI as an Architecture Question: Agentic UI Between AI Freedom and Control
manfredsteyer
PRO
0
92
AI-Ready Angular Architectures Architecture as Executable Contract
manfredsteyer
PRO
0
250
Nostalgia Meets Technology: Super Mario with TypeScript @BASTA 2026 in Mainz, Germany
manfredsteyer
PRO
0
48
Beyond Chatbots: Agentic UI with Open Standards @AGNTcon 2026 in Amsterdam
manfredsteyer
PRO
0
150
Next-Level Frontends: Agentic Web UIs Under the Hood
manfredsteyer
PRO
0
110
Agentic UI with Open Standards @ngGraz Sep 2026
manfredsteyer
PRO
0
120
Agentic UI with Open Standards @GDG Salzburg, Bgl & Prishtina
manfredsteyer
PRO
0
98
Other Decks in Programming
See All in Programming
Are APIs Still Relevant in the AI Era?
soyuka
0
460
Verilogで学ぶCPU自作入門
uyuki234
8
4.1k
個人開発者よ、Honoを使え(おじさんver)
tanahiro2010
2
250
Kubernetes祭り #2 OP/ED
bells17
0
110
コーディング自動化の次へ。人の介入をゼロにするファクトリーとサポートAIによる実践
timakin
0
920
wkhtmltopdfの次どうするか問題2026
willnet
2
1.9k
Event is what happens
moro
1
190
Agents on Rails - Rails at Scale 2026
irinanazarova
0
530
最近”作らせてる” ローカルAIアプリの話
akit37
0
450
難しいけど、読めた。- OSSの入口に立った話。
sts11142
0
150
パスワード再設定メールのURLについて知っておこう
uyuki234
0
140
AIに “答え“を書かせるのを やめてみた
___akari11
0
120
Featured
See All Featured
Bioeconomy Workshop: Dr. Julius Ecuru, Opportunities for a Bioeconomy in West Africa
akademiya2063
PRO
1
400
The Spectacular Lies of Maps
axbom
PRO
1
1.1k
GraphQLの誤解/rethinking-graphql
sonatard
75
12k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
250
1.3M
Google's AI Overviews - The New Search
badams
0
1.6k
A Soul's Torment
seathinner
8
3.7k
How To Stay Up To Date on Web Technology
chriscoyier
790
250k
ラッコキーワード サービス紹介資料
rakko
1
5.3M
Learning to Love Humans: Emotional Interface Design
aarron
275
41k
A better future with KSS
kneath
240
18k
B2B Lead Gen: Tactics, Traps & Triumph
marketingsoph
1
280
Navigating the Design Leadership Dip - Product Design Week Design Leaders+ Conference 2024
apolaine
2
470
Transcript
@ManfredSteyer Angular Elements Workshop Manfred Steyer SOFTWAREarchitekt.at ManfredSteyer
@ManfredSteyer ✓ Commodore 64 ✓ 1982 ✓ ~ 1 MHz
✓ 64 KB RAM ✓ Disks with 170 KB
@ManfredSteyer Version with two cores ;-) Challenge: Resources!
@ManfredSteyer Long Time Maintain- ability Maintain + Extend for 10
+/- yrs
@ManfredSteyer There are milk products lasting longer than some JavaScript
frameworks
@ManfredSteyer About me… • Manfred Steyer • SOFTWAREarchitekt.at • Angular
Trainings and Consultancy • Google Developer Expert (GDE) • Trusted Collaborator for Angular Page ▪ 6 Manfred Steyer Public: München, Frankfurt, Wien In-House: everywhere http://www.softwarearchitekt.at
@ManfredSteyer Contents • Web Components • Using Web Components in
Angular • Web Components with Angular Elements • Lazy and External Web Components • Building Web Components • Zone-less Change Detection • Content Projection
@ManfredSteyer Web Components
@ManfredSteyer Framework independent Components
@ManfredSteyer Umbrella Term for several Standards
@ManfredSteyer Standards Templates HTML Imports Custom Elements Shadow DOM
@ManfredSteyer Templates Markup that is rendered but not displayed Can
be displayed when needed, e. g. within components <template><span class="number"></span> Records found</template>
@ManfredSteyer Custom Elements Custom HTML-Element, e. g. <date-picker> Behaves like
build-in ones Write once; consume with any framework
@ManfredSteyer Examples <slider min="0" max="100"> … <customer-selector selected="selected()"> … <my-micro-app
state="sharedState" message="handle(…)">…
@ManfredSteyer Shadow DOM Isolate CSS Parent cannot influence Component's layout
Component cannot influence Parent or Siblings
@ManfredSteyer Possibilities Widget Libraries Enriching existing Apps Migrating Legacy Apps
CMS Integration UI Integration/ Composition Micro Apps
@ManfredSteyer All this can be polyfilled down to IE11 (more
or less)
@ManfredSteyer Polyfill
@ManfredSteyer Selected Polyfills • webcomponents-loader.js • Loads Polyfills on demand
• Custom Elements • Shadom DOM • Templates • native-shim.js • Needed for browsers that DO support polyfills … • … as long as we downlevel to ES5
@ManfredSteyer API class HelloElement extends HTMLElement { […] }
@ManfredSteyer API class HelloElement extends HTMLElement { constructor() { super();
this.attachShadow({mode: 'open'}); this.shadowRoot.innerHTML = '<div>Hello World</div>'; } […] }
@ManfredSteyer API class HelloElement extends HTMLElement { constructor() { super();
this.attachShadow({mode: 'open'}); this.shadowRoot.innerHTML = '<div>Hello World</div>'; } […] } customElements.define('hello-world', HelloElement);
@ManfredSteyer Calling a Web Component <hello-world></hello-world>
@ManfredSteyer Using Properties class HelloElement extends HTMLElement { get name()
{ […] } set name(value: string) { … } constructor() { […] } […] }
@ManfredSteyer Using Properties <!-- Property Binding with Angular --> <hello-world
[name]="firstName"></hello-world> <hello-world [name]="'Max'"></hello-world> <!-- VanillaJS --> var elm = document.getElementById(…) elm['name'] = max;
@ManfredSteyer Using Attributes <hello-world name="Max"></hello-world> Not a property!!
@ManfredSteyer Component Callbacks & Co. • attributeChangedCallback(name, oldValue, newValue) •
static get observedAttributes • connectedCallback • disconnectedCallback • adoptedCallback
@ManfredSteyer DEMO
@ManfredSteyer Angular Elements
@ManfredSteyer Angular Elements Wrap Angular Components Expose Custom Elements
@ManfredSteyer Angular Elements @NgModule({ imports: [BrowserModule], declarations: [DateComponent], entryComponents: [DateComponent]
}) export class AppModule { }
@ManfredSteyer Angular Elements @NgModule({ imports: [BrowserModule], declarations: [DateComponent], entryComponents: [DateComponent]
}) export class AppModule { }
@ManfredSteyer Angular Elements @NgModule({ imports: [BrowserModule], declarations: [DateComponent], entryComponents: [DateComponent]
}) export class AppModule { constructor(private injector: Injector) { } }
@ManfredSteyer Angular Elements @NgModule({ imports: [BrowserModule], declarations: [DateComponent], bootstrap: [],
entryComponents: [DateComponent] }) export class AppModule { constructor(private injector: Injector) { const DateElement = createCustomElement( DateComponent, { injector: this.injector }); customElements.define('date-picker', DateElement); } }
@ManfredSteyer Angular (Elements) & Shadow DOM • Baked-in • Default:
Emulation • @Component({ encapsulation: ViewEncapsulation.Emulated }) • Shadow DOM (v0) • @Component({ encapsulation: ViewEncapsulation.Native }) • Shadow DOM (v1) • @Component({ encapsulation: ViewEncapsulation.ShadowDom }) • Can be turned off: • @Component({ encapsulation: ViewEncapsulation.None })
@ManfredSteyer DEMO
@ManfredSteyer Differential Serving
@ManfredSteyer All your users pay for IE 11! • Polyfills:
~ 150 KB • Even custom elements polyfills for browsers that DO support custom elements b/c of ES5 • ES5: Bigger, less optimized
@ManfredSteyer Differential Serving • Provide modern ES2015+ bundels w/o polyfills
• Provide legacy ES5 bundles w/ polyfills • Let browser decide which to load
@ManfredSteyer How can browser decide? <script src="legacy.js" nomodule></script> <script src="modern.js"
type="module"></script>
@ManfredSteyer Automation • Vue: --modern • Angular: ngx-build-modern • Soon:
Angular CLI 8
@ManfredSteyer DEMO
@ManfredSteyer Sharing Dependencies
@ManfredSteyer Bundles Custom Element 1 Custom Element 2 Custom Element
3 Libraries: Angular, RxJS, … Libraries: Angular, RxJS, …
@ManfredSteyer Tree Shaking + ngIvy (Angular 8.x?) Custom Element 1
Custom Element 2 Custom Element 3
@ManfredSteyer
@ManfredSteyer Where Ivy can help ✓ Widgets based on @angular/core,
@angular/common Libs like @angular/forms or @angular/router
@ManfredSteyer Sharing Libs Custom Element 1 Custom Element 2 Custom
Element 3 Libraries: Angular, RxJS, … UMD ngx-build-plus Drawbacks: Complexity, no isolation
@ManfredSteyer DEMO
@ManfredSteyer Zone-less Change Detection
@ManfredSteyer Why zone.js? • Used by Angular's changed detection •
Patches each browser event • Notifies Angular after each event handler
@ManfredSteyer Why not zone.js? • 127 KB (12 gzipped) •
Awkward to force consumers of our web components to load zone.js
@ManfredSteyer How to exclude it? platformBrowserDynamic().bootstrapModule(AppModule, {ngZone: 'noop'})
@ManfredSteyer Consequences • Manual Change Detection • Change Detection via
Observables
@ManfredSteyer DEMO
@ManfredSteyer Content Projection
@ManfredSteyer Panel
@ManfredSteyer Calling a Tab <my-tab title="Page 1"> Lorem ipsum, dolor
sit amet … <div slot="footer">Some extra info</div> </my-tab>
@ManfredSteyer Implementation <div id="tab"> <h2>{{title}}</h2> <div id="content"> <slot></slot> </div> </div>
@ManfredSteyer Implementation <div id="tab"> <h2>{{title}}</h2> <div id="content"> <slot></slot> <div class="small">
<slot name="footer"></slot> </div> </div> </div>
@ManfredSteyer Slot API • ShadowDOM v1 • ViewEncapsulation.ShadowDom
@ManfredSteyer DEMO
@ManfredSteyer Summary Polyfills and CUSTOM ELEMENTS_SCHEMA Directives for Two-Way-Binding Lazy
& External Web Components Build Strategies: Differential Serving Sharing Code Zone-less Slot API
@ManfredSteyer Contact and Downloads [mail]
[email protected]
[web] SOFTWAREarchitekt.at [twitter] ManfredSteyer
d Blog about this stuff