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 the Basics @ngconf 2019
Search
Manfred Steyer
PRO
May 01, 2019
Programming
2
980
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 with Modern Angular and Island Architectures @ijs London 2024
manfredsteyer
PRO
0
59
Modern State Management in Angular: 3+n Flavors of the Signal Store @ijs London 2024
manfredsteyer
PRO
0
46
Changed Rules: Architectures with Lightweight Stores
manfredsteyer
PRO
0
230
Migrating to Signals: A Practical Workshop
manfredsteyer
PRO
0
390
Micro Frontends with Web Standards
manfredsteyer
PRO
1
290
The New NGRX Signal Store for Angular: 3+n Flavors
manfredsteyer
PRO
1
210
Leveraging the new NGRX Signal Store
manfredsteyer
PRO
0
170
Modern State Management in Angular: The 3+n Flavors of the NGRX Signal Store
manfredsteyer
PRO
0
100
NGRX Signal Store
manfredsteyer
PRO
0
200
Other Decks in Programming
See All in Programming
CircleCIを活用して AWSへの継続的デリバリーを 実践する
coconala_engineer
1
230
OpenTelemetry のサービスという概念について
azukiazusa1
2
1.1k
OpenAPIを中心に考えるAPI開発入門 / Introduction to API Development with a Focus on OpenAPI
seike460
PRO
2
110
1인 개발자로 행복하게 살기 - GDG 송도 헬로월드 2024
benjaminkim
1
5.6k
スクラムガイドのスプリントレトロスペクティブを改めて読みかえしてみた / Re-reading the Sprint Retrospective Section in the Scrum Guide
mackey0225
3
330
Designing for tomorrow's programming workflows
honnibal
PRO
2
110
オブジェクト指向のリ・オリエンテーション~歴史を振り返り、AI時代に向きなおる~
hanyudaeiiti
9
5.6k
Folding Cheat Sheet #3
philipschwarz
PRO
0
110
GitHub Actionsで泣かないためにやっておきたい設定 / Recommended GHA settings to avoid crying
pinkumohikan
3
490
受託開発でGitLab CI を活用していく
xiombatsg
1
270
Folding Cheat Sheet #2
philipschwarz
PRO
0
110
App Router への移行は「改善」となり得るのか?/ Can migration to App Router be an improvement
takefumiyoshii
8
2.1k
Featured
See All Featured
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
220
21k
Visualization
eitanlees
135
14k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
240
1.2M
How GitHub Uses GitHub to Build GitHub
holman
468
290k
[RailsConf 2023] Rails as a piece of cake
palkan
22
3.9k
The Language of Interfaces
destraynor
151
23k
Reflections from 52 weeks, 52 projects
jeffersonlam
344
19k
In The Pink: A Labor of Love
frogandcode
138
21k
Six Lessons from altMBA
skipperchong
20
3k
Keith and Marios Guide to Fast Websites
keithpitt
408
22k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
39
4.4k
Principles of Awesome APIs and How to Build Them.
keavy
120
16k
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