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 Elements: Beyond th...
Search
Manfred Steyer
PRO
May 01, 2019
Programming
2
1.1k
Web Components with Angular Elements: Beyond the Basics @ngconf 2019
Manfred Steyer
PRO
May 01, 2019
Tweet
Share
More Decks by Manfred Steyer
See All by Manfred Steyer
Micro Frontends Unmasked Opportunities, Challenges, Alternatives
manfredsteyer
PRO
0
110
3 Effective Rules for Using Signals in Angular
manfredsteyer
PRO
0
120
Your Architecture as a Crime Scene: Improvements with Forensic Analysis @ijs Munich 2024
manfredsteyer
PRO
0
38
3 Effective Rules for Using Signals in Angular
manfredsteyer
PRO
0
100
Micro Frontends Unmasked: Opportunities, Challenges, Alternatives @w-jax 2024 München
manfredsteyer
PRO
0
91
3 Effective Rules for Using Signals in Angular
manfredsteyer
PRO
1
100
3 Effective Rules for Using Signals in Angular
manfredsteyer
PRO
0
61
Modern Angular: Renovation for Your Applications
manfredsteyer
PRO
0
250
Vertical Architectures for Scalable Angular Applications
manfredsteyer
PRO
0
370
Other Decks in Programming
See All in Programming
.NET のための通信フレームワーク MagicOnion 入門 / Introduction to MagicOnion
mayuki
1
1.8k
카카오페이는 어떻게 수천만 결제를 처리할까? 우아한 결제 분산락 노하우
kakao
PRO
0
110
subpath importsで始めるモック生活
10tera
0
320
どうして僕の作ったクラスが手続き型と言われなきゃいけないんですか
akikogoto
1
120
광고 소재 심사 과정에 AI를 도입하여 광고 서비스 생산성 향상시키기
kakao
PRO
0
170
レガシーシステムにどう立ち向かうか 複雑さと理想と現実/vs-legacy
suzukihoge
14
2.3k
watsonx.ai Dojo #4 生成AIを使ったアプリ開発、応用編
oniak3ibm
PRO
1
150
Realtime API 入門
riofujimon
0
150
『ドメイン駆動設計をはじめよう』のモデリングアプローチ
masuda220
PRO
8
540
型付き API リクエストを実現するいくつかの手法とその選択 / Typed API Request
euxn23
8
2.3k
CSC509 Lecture 09
javiergs
PRO
0
140
Click-free releases & the making of a CLI app
oheyadam
2
120
Featured
See All Featured
What's new in Ruby 2.0
geeforr
343
31k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
25
1.8k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
27
840
We Have a Design System, Now What?
morganepeng
50
7.2k
Automating Front-end Workflow
addyosmani
1366
200k
Designing for humans not robots
tammielis
250
25k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
47
5k
Side Projects
sachag
452
42k
Being A Developer After 40
akosma
87
590k
The Language of Interfaces
destraynor
154
24k
How to train your dragon (web standard)
notwaldorf
88
5.7k
Keith and Marios Guide to Fast Websites
keithpitt
409
22k
Transcript
@ManfredSteyer Web Components with Angular Elements: Beyond the Basics Manfred
Steyer SOFTWAREarchitekt.at ManfredSteyer
@ManfredSteyer
@ManfredSteyer [Igor Minar, Angular Connect 2018 Keynote]
@ManfredSteyer
@ManfredSteyer Angular Elements
@ManfredSteyer Custom Elements: Framework independent components
@ManfredSteyer Possibilities Component Libraries Enriching existing Apps CMS Integration Dynamic
Loading
@ManfredSteyer Contents • Basics (just one slide) • Dynamically adding
elements • Lazy loading elements • External elements • Bundle Size
@ManfredSteyer About me … • Manfred Steyer SOFTWAREarchitekt.at • Angular
Trainings and Consultancy • Google Developer Expert (GDE) • Angular Trusted Collaborator Page ▪ 9 Manfred Steyer Public: Vienna, Munich, Frankfurt In-House: Everywhere in Europe http://www.softwarearchitekt.at/workshops
@ManfredSteyer 1) Basics
@ManfredSteyer Angular Elements Wrap Angular Components: createCustomElement(…) Register it with
browser: customElements.define(…)
@ManfredSteyer 2) Dynamic 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([…]) otherElement.appendChild(tile); Angular uses Domino to simulate document for SSR!
@ManfredSteyer DEMO
@ManfredSteyer 3) Lazy Loading
@ManfredSteyer 2 Steps for Lazy Elements Register module in angular.json
Load with with NgModuleFactoryLoader
@ManfredSteyer Register in angular.json "lazyModules": [ "[…]/lazy-dashboard-tile.module" ],
@ManfredSteyer Loading your module @Injectable({ providedIn: 'root' }) export class
LazyDashboardTileService { }
@ManfredSteyer Loading your module @Injectable({ providedIn: 'root' }) export class
LazyDashboardTileService { constructor( private loader: NgModuleFactoryLoader, private injector: Injector ) {} }
@ManfredSteyer Loading your module @Injectable({ providedIn: 'root' }) export class
LazyDashboardTileService { constructor( private loader: NgModuleFactoryLoader, private injector: Injector ) {} load(): Promise<void> { const path = '[…]/lazy-dashboard-tile.module‘; […] } }
@ManfredSteyer Loading your module @Injectable({ providedIn: 'root' }) export class
LazyDashboardTileService { constructor( private loader: NgModuleFactoryLoader, private injector: Injector ) {} load(): Promise<void> { const path = '[…]/lazy-dashboard-tile.module'; return this.loader.load(path).then(moduleFactory => { }); } }
@ManfredSteyer Loading your module @Injectable({ providedIn: 'root' }) export class
LazyDashboardTileService { constructor( private loader: NgModuleFactoryLoader, private injector: Injector ) {} load(): Promise<void> { const path = '[…]/lazy-dashboard-tile.module'; return this.loader.load(path).then(moduleFactory => { moduleFactory.create(this.injector); }); } }
@ManfredSteyer DEMO
@ManfredSteyer 4) External Elements
@ManfredSteyer Project A Custom Element Custom Element Bundle Project B
@ManfredSteyer Create application for Custom Elements Compile application to self
contained bundle Load bundle into consumer 3 Steps
@ManfredSteyer Compile to self-contained bundle
@ManfredSteyer ng add ngx-build-plus
@ManfredSteyer One of the simplest bundle loaders … const script
= document.createElement('script'); script.src = 'assets/external-dashboard-tile.bundle.js'; document.body.appendChild(script);
@ManfredSteyer DEMO
@ManfredSteyer 5) Bundle Size
@ManfredSteyer Bundles Custom Element 1 Custom Element 2 Custom Element
3 Libraries: Angular, RxJS, … Libraries: Angular, RxJS, …
@ManfredSteyer Angular Elements + Ivy Custom Element 1 Custom Element
2 Custom Element 3
@ManfredSteyer Where Ivy can help ✓ UI-based Widgets ✓ Libraries
@ManfredSteyer Sharing Libs Custom Element 1 Custom Element 2 Custom
Element 3 Libraries: Angular, RxJS, … Drawbacks: Complexity, non-default build, …
@ManfredSteyer Summary Reuse with other technologies Dynamically Adding Lazy Loading
External Elements Ivy for UI-based Code Sharing Dependencies
@ManfredSteyer Sometimes, all we want is a greasy pizza!
@ManfredSteyer Blog > SOFTWAREarchitekt.at • Angular Elements, Part I: A
Dynamic Dashboard In Four Steps With Web Components […] • Angular Elements, Part V: Your Options For Building Angular Elements With The CLI
@ManfredSteyer Workshop: Tomorrow A Deep Look at Angular Elements With
live coding and exercises for you on StackBlitz Thu, May 2:30 pm - 4:30 pm
@ManfredSteyer Contact and Downloads [mail]
[email protected]
[web] SOFTWAREarchitekt.at [twitter] ManfredSteyer
d http://softwarearchitekt.at/workshops Slides & Examples