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
Angular Elementsにハマってみた/I use the Angular Elements
Search
Eiji Hachiya
January 29, 2020
1.1k
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Angular Elementsにハマってみた/I use the Angular Elements
2020/01/29(水) に行われたClassiAngularNight #5の資料です
Eiji Hachiya
January 29, 2020
More Decks by Eiji Hachiya
See All by Eiji Hachiya
夏休みWebアプリパフォーマンス相談室/web-app-performance-on-radio
hachi_eiji
2
1.1k
なぜClassiはReactが盛り上がってる2017年にAngularを選択したのか?/why we use angular
hachi_eiji
2
1.8k
【Real Tech Night #2】学校教育を支えるマルチテナント/multi-tenant_in_edtech
hachi_eiji
1
330
レガシー業界の社内を変える /realtech
hachi_eiji
0
550
Featured
See All Featured
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
Agile that works and the tools we love
rasmusluckow
331
22k
B2B Lead Gen: Tactics, Traps & Triumph
marketingsoph
0
230
Un-Boring Meetings
codingconduct
0
410
Applied NLP in the Age of Generative AI
inesmontani
PRO
4
2.4k
What’s in a name? Adding method to the madness
productmarketing
PRO
24
4.2k
Hiding What from Whom? A Critical Review of the History of Programming languages for Music
tomoyanonymous
3
1.2k
First, design no harm
axbom
PRO
2
1.3k
Music & Morning Musume
bryan
47
7.4k
Bioeconomy Workshop: Dr. Julius Ecuru, Opportunities for a Bioeconomy in West Africa
akademiya2063
PRO
1
350
Darren the Foodie - Storyboard
khoart
PRO
3
3.9k
Heart Work Chapter 1 - Part 1
lfama
PRO
8
36k
Transcript
Copyright © 2020 Classi Corp. All Rights Reserved. Angular Elementsでハマってみた
2020/01/29 Classi Angular Night #5
Copyright © 2020 Classi Corp. All Rights Reserved. • 八谷
英治 (はちや えいじ) • Twitter hachi_eiji • Classi株式会社 • エンジニアリングマネージャー 1 自己紹介
Copyright © 2020 Classi Corp. All Rights Reserved. AngularJS使ってますか!! 2
https://connpass.com/event/78163/presentation/
Copyright © 2020 Classi Corp. All Rights Reserved. AngularJS •
Angular Elementsを使う Angular Elements概要 • Angular ElementsによるAngularJSの段階的アップグレード戦略 AngularJS の中でAngularを動かす 3 Angularで作った コンポーネント Angularで作った コンポーネント Angularで作った コンポーネント Angularで作った コンポーネント Angularで作った コンポーネント Custom Element
Copyright © 2020 Classi Corp. All Rights Reserved. この部分だけAngular Elementsを使う
4
Copyright © 2020 Classi Corp. All Rights Reserved. リロードすると見えたり、見えなかったりする みんな大好き
IE/Edgeだけ動かない(ことが多々ある) 5
Copyright © 2020 Classi Corp. All Rights Reserved. 原因はAngular Elementsの起動順番にあった
6 Angular Elements AngularJS ① Load Script ② Load Script ①’ bootstrap ②’ bootstrap 時間 Angularのコンポーネントを呼び出すために AngularJSのbootstrapを呼び出す前に Angularの初期化を終わせる必要があった
Copyright © 2020 Classi Corp. All Rights Reserved. 解決案その1 7
Angular Elements AngularJS ① Load Script ② Load Script ③ bootstrap ④ bootstrap 時間 問題点 ③が終わる前に④のイベントを待受イベン トの起動完了させないと空振りが起きる AngularJS側の 起動Eventを投げる platformBrowserDynamic() .bootstrapModule(<モジュール名>) .then((moduleRef) => { defineCustomElements(moduleRef.injector); }) .then(() => { // AngularJSを呼び出す前にAngularの初期化を終わらせたい // angularJSElementInitialized イベントはAngularJS側に記載する const event = new Event('angularJSElementInitialized'); window.dispatchEvent(event); })
Copyright © 2020 Classi Corp. All Rights Reserved. 最終的な解決案 8
Angular Elements AngularJS ① Load Script ② Load Script ③ bootstrap ④ bootstrap 時間 Promise.thenで イベントを起動する window.addEventListener('DOMContentLoaded', function () { // initializeElementはAngular Element上で定義済み window['initializeElement']().then(function () { angular.bootstrap(document, ['classi']); }); });
Copyright © 2020 Classi Corp. All Rights Reserved. 大切なことなのでもう一度 9
https://connpass.com/event/78163/presentation/
Copyright © 2020 Classi Corp. All Rights Reserved. 2021年に終わるので徐々に変えていき 10