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: Beyond the basics
Search
Manfred Steyer
PRO
March 22, 2019
Programming
430
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Web Components with Angular: Beyond the basics
Manfred Steyer
PRO
March 22, 2019
More Decks by Manfred Steyer
See All by Manfred Steyer
Generative UI & AI-Assistants for Your Angular Solutions
manfredsteyer
PRO
1
180
Generative UI & AI-Assistants for Your Angular Solutions
manfredsteyer
PRO
0
110
Nostalgia Meets Technology: Super Mario with TypeScript
manfredsteyer
PRO
0
180
Signal Forms: Details & Live Coding @enterJS 2026 in Mannheim
manfredsteyer
PRO
0
230
Strategic Design in the Frontend: Moduliths & Micro Frontends @DDDEurope
manfredsteyer
PRO
0
160
Agentic UI
manfredsteyer
PRO
0
230
Signal Forms: Beyond the Basics @ngBaguette 2026 in Paris
manfredsteyer
PRO
0
290
Agentic UI beyond Chats Architecture Patterns & Open Standards @ngMunich 05/2026
manfredsteyer
PRO
0
240
Agentic AI in the Frontend: Architectures with Open Standards @iJS London 2026
manfredsteyer
PRO
0
170
Other Decks in Programming
See All in Programming
琵琶湖の水は止められてもNet--HTTPのリトライは止められない / You might be able to stop the water flow of Lake Biwa but you can't stop Net::HTTP retries
luccafort
PRO
0
380
20260623_Loop Engineeringで自分の分身の問い合わせBotを作る
ryugen04
0
220
AIを活用したE2Eテスト実装効率化のあゆみ / ebisu-mobile-14-kotetu
kotetuco
0
170
ルールを書いて終わらせないハーネスエンジニアリング
yug1224
2
1.4k
yield再入門 #phpcon
o0h
PRO
0
360
광주소프트웨어마이스터고등학교 DevFest 특강 - 바이브 코딩 시대에서 주니어 개발자로 살아남는 방법
utilforever
1
130
『コードを書く以外の』エンジニアリング〜課金基盤移行プロジェクト推進のためのTips4選
yuriko1211
0
500
Apache Hive: Toward a Cloud Native Lakehouse
okumin
0
120
継続モナドとリアクティブプログラミング
yukikurage
3
600
言語を使う側から、作る側へ。 自作 Lisp で得た新たな気づき。
andpad
0
120
5分で問診!Composer セキュリティ健康診断
codmoninc
0
250
「正の参照」と 「負の導出」で組む ハーネスエンジニアリング
cottpan
1
140
Featured
See All Featured
The #1 spot is gone: here's how to win anyway
tamaranovitovic
3
1.1k
SERP Conf. Vienna - Web Accessibility: Optimizing for Inclusivity and SEO
sarafernandez
2
1.5k
Data-driven link building: lessons from a $708K investment (BrightonSEO talk)
szymonslowik
1
1.2k
How GitHub (no longer) Works
holman
316
150k
Balancing Empowerment & Direction
lara
6
1.2k
Building a Modern Day E-commerce SEO Strategy
aleyda
45
9.1k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
How STYLIGHT went responsive
nonsquared
100
6.2k
The innovator’s Mindset - Leading Through an Era of Exponential Change - McGill University 2025
jdejongh
PRO
1
220
The World Runs on Bad Software
bkeepers
PRO
72
12k
Navigating Team Friction
lara
192
16k
The Power of CSS Pseudo Elements
geoffreycrofte
82
6.4k
Transcript
@ManfredSteyer Web Components with Angular: Beyond the basics Manfred Steyer
SOFTWAREarchitekt.at ManfredSteyer
@ManfredSteyer About me … • Manfred Steyer SOFTWAREarchitekt.at • Angular
Trainings and Consultancy • Google Developer Expert (GDE) • Angular Trusted Collaborator Page ▪ 2 Manfred Steyer Public: Vienna, Munich, Frankfurt In-House: Everywhere in Europe http://www.softwarearchitekt.at/workshops
@ManfredSteyer Contents • Motivation & Angular Elements 101 • Polyfills
• Dynamic & Lazy elements • External elements • Dealing with dependencies • Excluding Zone.js
@ManfredSteyer Motivation
@ManfredSteyer Web Components: Framework independent components
@ManfredSteyer Standards Templates HTML Imports Custom Elements Shadow DOM
@ManfredSteyer Some Possibilities … Widget Libraries CMS Integration Enriching existing
Apps Migrating Legacy Apps
@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 CUSTOM_ELEMENTS_SCHEMA @NgModule({ […], schemas: [ CUSTOM_ELEMENTS_SCHEMA ] }) export
class MyModule {}
@ManfredSteyer DEMO
@ManfredSteyer Polyfills
@ManfredSteyer Distribution
@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 a we downlevel to ES5
@ManfredSteyer DEMO
@ManfredSteyer Dynamic and Lazy Elements
@ManfredSteyer Adding Custom Elements dynamically const tile = document.createElement('dashboard-tile');
@ManfredSteyer Adding Custom Elements dynamically const tile = document.createElement('dashboard-tile‘); tile['prop']
= 123; tile.setAttribute('class', 'col-lg-4 col-md-3 col-sm-2') tile.addEventListener([…])
@ManfredSteyer Adding Custom Elements dynamically const tile = document.createElement('dashboard-tile‘); tile['prop']
= 123; tile.setAttribute('class', 'col-lg-4 col-md-3 col-sm-2') tile.addEventListener([…]) content.appendChild(tile);
@ManfredSteyer Lazy Loading Register module in angular.json Load with with
NgModuleFactoryLoader
@ManfredSteyer Register in angular.json "lazyModules": [ "[…]/lazy-dashboard-tile.module.ts" ],
@ManfredSteyer Register in angular.json @Injectable({ providedIn: 'root' }) export class
LazyDashboardTileService { }
@ManfredSteyer Register in angular.json @Injectable({ providedIn: 'root' }) export class
LazyDashboardTileService { constructor( private loader: NgModuleFactoryLoader, private injector: Injector ) {} }
@ManfredSteyer Register in angular.json @Injectable({ providedIn: 'root' }) export class
LazyDashboardTileService { constructor( private loader: NgModuleFactoryLoader, private injector: Injector ) {} load(): Promise<void> { return this.loader.load(path).then(moduleFactory => { }); } }
@ManfredSteyer Register in angular.json @Injectable({ providedIn: 'root' }) export class
LazyDashboardTileService { constructor( private loader: NgModuleFactoryLoader, private injector: Injector ) {} load(): Promise<void> { return this.loader.load(path).then(moduleFactory => { moduleFactory.create(this.injector); […] }); } }
@ManfredSteyer DEMO
@ManfredSteyer External Elements
@ManfredSteyer Project A Custom Element Custom Element Bundle Project B
@ManfredSteyer Register Custom Element when bootstrapping Compile application to self
contained bundle Load bundle into consumer 3 Steps
@ManfredSteyer Register when bootstrapping @NgModule({ […] bootstrap: [] }) export
class AppModule { }
@ManfredSteyer Register when bootstrapping @NgModule({ […] bootstrap: [] }) export
class AppModule { constructor(private injector: Injector) { } ngDoBootstrap() { } }
@ManfredSteyer Register when bootstrapping @NgModule({ […] bootstrap: [], }) export
class AppModule { constructor(private injector: Injector) { } ngDoBootstrap() { const externalTileCE = createCustomElement( ExternalDashboardTileComponent, { injector: this.injector }); customElements.define('external-dashboard-tile', externalTileCE); } }
@ManfredSteyer Compile to self-contained bundle
@ManfredSteyer ngx-build-plus: --single-bundle
@ManfredSteyer Load into consumer const script = document.createElement('script'); script.src =
'assets/external-dashboard-tile.bundle.js'; document.body.appendChild(script);
@ManfredSteyer DEMO
@ManfredSteyer Dealing with Dependencies
@ManfredSteyer Bundles Custom Element 1 Custom Element 2 Custom Element
3 Libraries: Angular, RxJS, … Libraries: Angular, RxJS, …
@ManfredSteyer Tree Shaking + Ivy (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 Drawbacks: Complexity, no isolation
@ManfredSteyer DEMO
@ManfredSteyer Excluding Zone.js
@ManfredSteyer How to exclude it? platformBrowserDynamic().bootstrapModule(AppModule, {ngZone: 'noop'})
@ManfredSteyer Consequences • Manual Change Detection • Change Detection via
Observables
@ManfredSteyer DEMO
@ManfredSteyer Summary Polyfills Adding dynamically Lazy loading Compiling and loading
external elements Dependencies Zone.js
@ManfredSteyer Contact and Downloads [mail]
[email protected]
[web] SOFTWAREarchitekt.at [twitter] ManfredSteyer
d Slides & Examples Public and In-House http://www.softwarearchitekt.at/workshops