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
Web Components with Angular: Workshop @MobileTe...
Search
Manfred Steyer
PRO
March 25, 2019
Programming
370
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
Generative UI & AI-Assistants for Your Angular Solutions
manfredsteyer
PRO
1
310
Generative UI & AI-Assistants for Your Angular Solutions
manfredsteyer
PRO
0
150
Nostalgia Meets Technology: Super Mario with TypeScript
manfredsteyer
PRO
0
220
Signal Forms: Details & Live Coding @enterJS 2026 in Mannheim
manfredsteyer
PRO
0
250
Strategic Design in the Frontend: Moduliths & Micro Frontends @DDDEurope
manfredsteyer
PRO
0
180
Agentic UI
manfredsteyer
PRO
0
260
Signal Forms: Beyond the Basics @ngBaguette 2026 in Paris
manfredsteyer
PRO
0
310
Agentic UI beyond Chats Architecture Patterns & Open Standards @ngMunich 05/2026
manfredsteyer
PRO
0
260
Agentic AI in the Frontend: Architectures with Open Standards @iJS London 2026
manfredsteyer
PRO
0
190
Other Decks in Programming
See All in Programming
ビデオ通話が繋がる0.2秒で何が起きているのか
supurazako
2
170
AI Engineeringは、AIプロダクトだけのものか? 〜AIがソフトウェアを作る時代の新しい当たり前〜 / No AI in your product. AI Engineering in your development.
rkaga
4
360
使いながら育てる Claude Code — 開発フローの1コマンド化 × 繰り返し指摘の自動仕組み化
shiki_kakaku
0
1.7k
言葉の格闘技のススメ~紙とペンと言葉から始める、キャリアの描き方~
progresscicada
1
120
自動化したのに回らないテスト運用の壁ーAI時代の品質責任と生産性
mfunaki
0
120
その節約、円になってますか?
isamumumu
1
680
PHP初心者セッション2026 〜生成AIでは見えない裏側を知る:今だからLAMPを通して仕組みを学ぶ〜
kashioka
0
820
Google Apps Script で Ruby を動かす
kawahara
0
130
AWS CDK を「作」ってみた 〜フルスクラッチで見えた CDK の裏側〜 / aws-cdk-from-scratch
gotok365
3
2.8k
jsmini JavaScript Engine を作ってみた話
yosuke_furukawa
PRO
0
290
freee が目指す データ マネジメント戦略 AI-Ready 時代を支える 攻めのガバナンスとは
freee
PRO
0
260
Built Our Own Background Agent at LayerX
layerx
PRO
9
4.9k
Featured
See All Featured
Building Experiences: Design Systems, User Experience, and Full Site Editing
marktimemedia
0
560
Lessons Learnt from Crawling 1000+ Websites
charlesmeaden
PRO
1
1.5k
What the history of the web can teach us about the future of AI
inesmontani
PRO
1
650
Kristin Tynski - Automating Marketing Tasks With AI
techseoconnect
PRO
0
440
GraphQLの誤解/rethinking-graphql
sonatard
75
12k
Raft: Consensus for Rubyists
vanstee
141
7.6k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
YesSQL, Process and Tooling at Scale
rocio
174
15k
HU Berlin: Industrial-Strength Natural Language Processing with spaCy and Prodigy
inesmontani
PRO
0
610
GraphQLとの向き合い方2022年版
quramy
50
15k
How Fast Is Fast Enough? [PerfNow 2025]
tammyeverts
3
700
Optimizing for Happiness
mojombo
378
71k
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