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
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
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.3k
なぜClassiはReactが盛り上がってる2017年にAngularを選択したのか?/why we use angular
hachi_eiji
2
1.8k
【Real Tech Night #2】学校教育を支えるマルチテナント/multi-tenant_in_edtech
hachi_eiji
1
340
レガシー業界の社内を変える /realtech
hachi_eiji
0
560
Featured
See All Featured
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
123
22k
Accessibility Awareness
sabderemane
1
290
Ten Tips & Tricks for a 🌱 transition
stuffmc
1
280
Marketing to machines
jonoalderson
1
6k
Effective software design: The role of men in debugging patriarchy in IT @ Voxxed Days AMS
baasie
1
600
Embracing the Ebb and Flow
colly
88
5.2k
Mobile First: as difficult as doing things right
swwweet
225
10k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
508
140k
Dominate Local Search Results - an insider guide to GBP, reviews, and Local SEO
greggifford
PRO
0
400
Chasing Engaging Ingredients in Design
codingconduct
0
390
Fireside Chat
paigeccino
43
4.1k
Taking LLMs out of the black box: A practical guide to human-in-the-loop distillation
inesmontani
PRO
3
2.5k
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