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
tkow-Angular2入門者の会発表資料
Search
tkow
October 14, 2016
Technology
1
13k
tkow-Angular2入門者の会発表資料
Leverages渋谷ヒカリエオフィスで開催された10/3 Angular2入門者の会で発表させていただいた際の
http://connpass.com/event/40251/
スライドです。
tkow
October 14, 2016
Tweet
Share
More Decks by tkow
See All by tkow
React NativeでCross Platform対応を頑張る話
tkow
1
690
Flipperを使ってみた rntb in Japan 2020/05/27
tkow
1
250
開発環境の切り分け方のベストプラクティスが分からない -andfactory20190917-
tkow
0
200
teratail_study
tkow
0
360
react-beginner
tkow
0
710
Other Decks in Technology
See All in Technology
AWS環境におけるランサムウェア攻撃対策の設計
nrinetcom
PRO
0
170
Server-Side Engineer of LINE Sukimani
lycorp_recruit_jp
0
360
生成AIのガバナンスの全体像と現実解
fnifni
1
210
Qiita埋め込み用スライド
naoki_0531
0
5.3k
re:Invent をおうちで楽しんでみた ~CloudWatch のオブザーバビリティ機能がスゴい!/ Enjoyed AWS re:Invent from Home and CloudWatch Observability Feature is Amazing!
yuj1osm
0
140
C++26 エラー性動作
faithandbrave
2
820
Working as a Server-side Engineer at LY Corporation
lycorp_recruit_jp
0
370
私なりのAIのご紹介 [2024年版]
qt_luigi
1
120
UI State設計とテスト方針
rmakiyama
3
800
効率的な技術組織が作れる!書籍『チームトポロジー』要点まとめ
iwamot
1
110
Google Cloud で始める Cloud Run 〜AWSとの比較と実例デモで解説〜
risatube
PRO
0
120
Storage Browser for Amazon S3
miu_crescent
1
290
Featured
See All Featured
Build The Right Thing And Hit Your Dates
maggiecrowley
33
2.4k
For a Future-Friendly Web
brad_frost
175
9.4k
Scaling GitHub
holman
459
140k
The Language of Interfaces
destraynor
154
24k
GraphQLの誤解/rethinking-graphql
sonatard
67
10k
Docker and Python
trallard
42
3.1k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
28
4.4k
Imperfection Machines: The Place of Print at Facebook
scottboms
266
13k
Fireside Chat
paigeccino
34
3.1k
Code Review Best Practice
trishagee
65
17k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
48k
How to train your dragon (web standard)
notwaldorf
88
5.7k
Transcript
creative commons by google.inc https://creativecommons.org/licenses/by-sa/3.0/ tutorialΛ௨͔ͯͬͨ͠ Angular2Ͱޮతʹ։ൃ͕։࢝ Ͱ͖ΔΑ͏ʹͳΔͨΊͷࣝ Takeo Kusama
Teratail account : tkow
ࣗݾհ ❖ ใܥͷେֶӃੜ म࢜̎ ❖ ϑϩϯτΤϯυ/όοΫΤϯυ྆ํΔਓ ❖ ։ൃܦݧ C#,C++,C,Java,Python,PHP,javascript,ruby,Swift,julia ❖
SIerͱϕϯνϟʔاۀͰϓϩάϥϚͷमߦΛ1΄Ͳ ❖ react,Angular1.xܥ৮ͬͨࣄ͕͋Γ·͕͢,Angular2ࠓճॳΊͯ ❖ དྷ͔ΒLeveragesͷࣾһʹͳΓ·͢
ҙ ❖ ՄಡੑͷͨΊ,JavascriptίʔυΛҰ෦CoffeeScriptͰ ༻͍ͯ͠·͕ྃ͢͝ঝ͍ͩ͘͞
ͳͥjQueryͰߦ͖٧·Δͷ͔ Γ͕ͪͳμϝͳίʔυ $lists = $(this).parents(‘ul’).children(‘li’) $(this).parents(‘#user_wrap’).find(‘title’).val(‘hoge’) $(this).parents(‘#user_wrap’).find(‘description’).val(‘f’) $(‘#post’).children(‘#post_text’).val(‘fuga’) ΩϟογϡͳͲͰ࠷దԽ͠ͳ͍ͱຖճͳDOMࠪΛ͢Δ Ұ؏ੑͷͳ͍selectorؒͷஔؔΛѲͮ͠Β͍(thisͱpostͷҐஔؔͳͲ)
ύϥϝʔλΛมߋ͢Δ͚ͩͳͷʹίʔυ͕͘ͳΔ ݁ہ,DOMͱσʔλߏ͕݁ͼ͍ͭͯͳ͍ͷ͕
ͳͥjQueryͰߦ͖٧·Δͷ͔ ៉ྷͳߏ apple = new Apple(‘red’) apple.color = ‘blue’ σʔλͷத͕มΘͬͨΒ,ಉ࣌ʹݟͨʹө͍͕ͨ͠
جຊతʹjsͰσʔλͷอ࣋ͱViewͷඳը͕͞Ε͍ͯΔ
ͳͥjQueryͰߦ͖٧·Δͷ͔ ❖ ͔ͭͯҰ؏ੑͷͳ͍selectorʹۤ͠ΊΒΕͨܦݧ͔Βಘͨݟ UIຖʹΫϥεΛ ࡞ΓೖͱDOMͷ มߋΛಉ࣌ʹ ߦ͏Α͏ʹͰ͖Δ … $(this).parents(‘#user_wrap’).find(‘title’).val(‘Hello’) $(this).parents(‘#user_wrap’).find(‘description’).val(‘World’)
… user1 = new UseWindow(form,1) … user1.title = ‘Hello’ user1.description = ‘World’ … ೖ࣌ʹupdate(Property) ϝιουʹΑͬͯDOMߋ৽
Angular2ॴײ ❖ Angular2ͰϓϩύςΟ·ͰࣗಈͰઃఆɻ ߋ৽༻ͷϝιουsetter ͷએݴෆཁ (Ͳ͏ͤ͜͏͍͏σʔλߏʹ͢ΔͷͰ͜ͷ࣌ ͰΘͳ͍ཧ༝͕ͳ͘ͳΓ·ͨ͠) ❖ Angular2(TS)ͷΫϥε
Angular2ॴײ ❖ typescriptʹΑׂͬͯຖʹ҆શʹϑΝΠϧΛ͢Δ͜ͱ͕༰қʹͳͬͨ Ϋϥε σίϨʔλ ΠϯλʔϑΣʔε ؔ Ռͯʹcss fileͳͲͰ͑͞ ͋ΒΏΔ
ΦϒδΣΫτΛexportͯ͠ pathࢦఆʹΑͬͯ ͖ͳॴͰimportͰ͖Δ
Angular2ཧղͷϙΠϯτ ❖ ཧղΛૣΊΔϙΠϯτ:తಠཱͨ͠ίϯϙʔωϯτΛ࡞Δ͜ͱ ɹ=>componentʹඞཁͳϑΝΠϧΛू ͢ΔΠϝʔδ Ϟσϧ αʔϏε Ϟδϡʔϧ ίϯϙʔωϯτ ମͷHTML
ίϯϙʔωϯτ ϩδοΫ σʔλ ػೳ ϩδοΫͱσʔλͱΠϕϯτ ͕ཧ͞ΕΔλάͷఆٛ
Angular2ཧղͷϙΠϯτ ❖ ཧղΛૣΊΔϙΠϯτ:తಠཱͨ͠ίϯϙʔωϯτΛ࡞Δ͜ͱ λά୯ҐͰૄ݁߹ʹͳΔ Ϟσϧૢ࡞Ҏ֎ͷϝιουmodule Ϋϥεͱͯ͠ ίϯϙʔωϯτͷ୯ҐΛ(js+html+css) ͱͯ͠UIຖʹಠཱʹઃఆ͢Δ͜ͱͰ ޓ͍ʹׯব͠ͳ͍UI͕࡞Γ͘͢ͳΔ ίϯϙʔωϯτͰఆٛ͞ΕΔϝιου
جຊతʹॳظԽͱΠϕϯτͷΈͰ݁͢Δ Ϟσϧૢ࡞ઐ༻ͷΫϥεͰϩδοΫΛ σʔλߏઐ༻ͷΫϥεͰૢ࡞ରΛ ɹ=>componentʹඞཁͳϑΝΠϧΛू ɹɹɹ͢ΔΠϝʔδ
Angular2࣮ફϙΠϯτ ❖ angluar2webpackʹΑͬͯtranspileͰ͖ΔͷͰ,ϓϩμΫτͷҠ২ੑ͕ߴ͍ ڥຖʹઃఆϑΝΠϧ ΛมߋՄೳ ίϯύΠϧͷରϑΝ ΠϧͷઃఆͳͲ webpack.*.js(*=dev)Ͱ distʹϑΝΠϧग़ྗઌΛ ࢦఆ͍ͯ͠Δ
Angular2࣮ફϙΠϯτ ❖ testઃఆϑΝΠϧ࡞ͬͯ npm testͰ࣮ߦՄೳ karmaͱPhantomJSͷઃఆΛpackage.jsonͰઃఆͰ͖ΔͨΊ,e2eςετ ͱ͔؆୯ʹͰ͖ΔͬΆ͍Ͱ͢ɻ
Angular2࣮ફϙΠϯτ ❖ webpack ߏͰಈ͘Α͏ʹͨ͠ͷ
[email protected]
:tkow/angular2_qs_with_webpack.git ʢhttps://angular.io/docs/ts/latest/guide/webpack.html ɹΛͳͧͬͨͷʣ
Angular2ॴײ ❖ ྑ͔ͬͨ ❖ ComponentͱLayout͕ग़དྷΔͷͰ࠶ར༻ੑ,มߋʹ͓͚Δॊೈੑ͕ߴ͍ ❖ CSSͷ͕ྑ͍(શମͷCSSΛѲ͠ͳͯ͘ྑ͍Έ) ❖ ΫϥΠΞϯταΠυRouting͕ڧྗ ❖
TypeScriptͷImport ,Exportͷ͕ؔΘ͔Γ͍͢ͷͰJSϑΝΠϧΛૄ݁߹ʹ͍͢͠ ❖ Pipe͕͍͢͝ ❖ γʔϜϨεʹView͕ߋ৽͞ΕΔͷ͕͍͢͝ ❖ react-native + angular2 ͱ͍͏ຯʹ͍͢͝ϚϧνϓϥοτϑΥʔϜ։ൃϓϩδδΣΫ τ͕࣮ݱ͍ͯ͠Δ ❖ ng-cli͕͔ͳΓظͰ͖Δ(railsίϚϯυฒΈʹศརʹͳΓͦ͏)
Angular2ॴײ ❖ ਏ͔ͬͨ ❖ ֶशίετߴ͍(TypeScript,ಠࣗͷsyntax,ActiveRouter,Component,Decorator,ng~) ❖ ώΞυΩϡϝϯτʹhtmlcssΛॻ͚ΔͷͰԿߟ͑ͣʹ͏ͱSyntaxindent͕ࠅ͍͜ͱʹͳΔ (ϑΝΠϧΛ͢Δ͜ͱͰղܾ) ❖ *ngForͳͲ,λάͷதʹίʔυΛॻ͘ͷʹҧײ(׳Εͷʁ)
❖ ֊͚ͳͲͷઃఆΛࣗͰ͠ͳ͍ͱ,τϥϯεύΠϧϑΝΠϧ͕ࢄΒ͔Δ(webpackͰjsͷग़ྗઌΛ มߋग़དྷͨͷͰ,ࠓޙͷنԽCLIʹΑΔࣗಈ֊͚ʹظ ɻ) ❖ ͋͘·ͰframeworkͳͷͰ,طଘͷprojectʹ͙͢ʹಋೖͰ͖Δੑ͋·Γͳ͍ײ͕ͨ͡͠ (webpackng-cliͳͲͰಠཱͨ͠applicationͱͯ͠طଘͷϓϩμΫτʹͭͳ͙ͷ؆୯ͦ͏) ❖ ઃఆϑΝΠϧଟ͗͢(ng-cliʹࣗಈԽؤுͬͯཉ͍͠) ❖ έόϒέʔεʹҧײ ❖ ΠϕϯτϑοΫΞχϝʔγϣϯΛ͚Δํ๏Λ·ͩશʹѲͰ͖͍ͯͳ͍(CSSϝΠϯͱ͍͏ᷚ)
Angular2ॴײ ❖ ·ͱΊ ❖ ཧ͕͍͠jsϑΝΠϧΛΧϓηϧԽ͢ΔͨΊςετΓ͘͢ อकੑ͕ߴ͍ͷͰ৽نϓϩδΣΫτͰ͍͚ͬͯͦ͏ ❖ ng-clinpm,webpackͳͲΛಋೖ͢Δ͜ͱͰ,τϥϯεύΠϧ࣌ͷ ϑΝΠϧཧ؆୯ʹͳΓͦ͏ ❖
ϑΝΠϧͷมߋʹରͯ͠,ଈ࣌ԠͳͷͰσόοά͍͢͠ ❖ ΞϓϦέʔγϣϯͷن͕͋·Γେ͖͘ͳ͚ΕطଘͷίʔυΛ ॻ͖͑Δίετͷํ͕ߴͦ͏ ❖ ͜ΕΛͬͱԡ͑͞ͱ͚ͱ͍͏͜ͱ͕͋Εੋඇڭ͍͑ͯͩ͘͞ɻ
Angular2ॴײ ❖ ࠓޙظ͢Δࣄௐ͍ͨࣄ ❖ hamlͱ͔ςϯϓϨʔτΤϯδϯ͍͍ͨ(Emmet͑Δ ͚Ͳ) ❖ ઃఆϑΝΠϧͷgenerator͕ྑ͘ͳͬͯ΄͍͠ ❖ ࠓճtutorialΛऴΘΒͤΔ·Ͱ͔͠ग़དྷͳ͔ͬͨͷͰ,࣮ࡍ
ʹϓϩμΫτΛ࡞ΔͷʹͬͯΈ͍ͨ