tkow-Angular2入門者の会発表資料
by
tkow
Link
Embed
Share
Beginning
This slide
Copy link URL
Copy link URL
Copy iframe embed code
Copy iframe embed code
Copy javascript embed code
Copy javascript embed code
Share
Tweet
Share
Tweet
Slide 1
Slide 1 text
creative commons by google.inc https://creativecommons.org/licenses/by-sa/3.0/ tutorialΛ௨͔ͯͬͨ͠ Angular2Ͱޮతʹ։ൃ͕։࢝ Ͱ͖ΔΑ͏ʹͳΔͨΊͷࣝ Takeo Kusama Teratail account : tkow
Slide 2
Slide 2 text
ࣗݾհ ❖ ใܥͷେֶӃੜ म࢜̎ ❖ ϑϩϯτΤϯυ/όοΫΤϯυ྆ํΔਓ ❖ ։ൃܦݧ C#,C++,C,Java,Python,PHP,javascript,ruby,Swift,julia ❖ SIerͱϕϯνϟʔاۀͰϓϩάϥϚͷमߦΛ1΄Ͳ ❖ react,Angular1.xܥ৮ͬͨࣄ͕͋Γ·͕͢,Angular2ࠓճॳΊͯ ❖ དྷ͔ΒLeveragesͷࣾһʹͳΓ·͢
Slide 3
Slide 3 text
ҙ ❖ ՄಡੑͷͨΊ,JavascriptίʔυΛҰ෦CoffeeScriptͰ ༻͍ͯ͠·͕ྃ͢͝ঝ͍ͩ͘͞
Slide 4
Slide 4 text
ͳͥ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ͱσʔλߏ͕݁ͼ͍ͭͯͳ͍ͷ͕
Slide 5
Slide 5 text
ͳͥjQueryͰߦ͖٧·Δͷ͔ ៉ྷͳߏ apple = new Apple(‘red’) apple.color = ‘blue’ σʔλͷத͕มΘͬͨΒ,ಉ࣌ʹݟͨʹө͍͕ͨ͠ جຊతʹjsͰσʔλͷอ࣋ͱViewͷඳը͕͞Ε͍ͯΔ
Slide 6
Slide 6 text
ͳͥ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ߋ৽
Slide 7
Slide 7 text
Angular2ॴײ ❖ Angular2ͰϓϩύςΟ·ͰࣗಈͰઃఆɻ ߋ৽༻ͷϝιουsetter ͷએݴෆཁ (Ͳ͏ͤ͜͏͍͏σʔλߏʹ͢ΔͷͰ͜ͷ࣌ ͰΘͳ͍ཧ༝͕ͳ͘ͳΓ·ͨ͠) ❖ Angular2(TS)ͷΫϥε
Slide 8
Slide 8 text
Angular2ॴײ ❖ typescriptʹΑׂͬͯຖʹ҆શʹϑΝΠϧΛ͢Δ͜ͱ͕༰қʹͳͬͨ Ϋϥε σίϨʔλ ΠϯλʔϑΣʔε ؔ Ռͯʹcss fileͳͲͰ͑͞ ͋ΒΏΔ ΦϒδΣΫτΛexportͯ͠ pathࢦఆʹΑͬͯ ͖ͳॴͰimportͰ͖Δ
Slide 9
Slide 9 text
Angular2ཧղͷϙΠϯτ ❖ ཧղΛૣΊΔϙΠϯτ:తಠཱͨ͠ίϯϙʔωϯτΛ࡞Δ͜ͱ ɹ=>componentʹඞཁͳϑΝΠϧΛू ͢ΔΠϝʔδ Ϟσϧ αʔϏε Ϟδϡʔϧ ίϯϙʔωϯτ ମͷHTML ίϯϙʔωϯτ ϩδοΫ σʔλ ػೳ ϩδοΫͱσʔλͱΠϕϯτ ͕ཧ͞ΕΔλάͷఆٛ
Slide 10
Slide 10 text
Angular2ཧղͷϙΠϯτ ❖ ཧղΛૣΊΔϙΠϯτ:తಠཱͨ͠ίϯϙʔωϯτΛ࡞Δ͜ͱ λά୯ҐͰૄ݁߹ʹͳΔ Ϟσϧૢ࡞Ҏ֎ͷϝιουmodule Ϋϥεͱͯ͠ ίϯϙʔωϯτͷ୯ҐΛ(js+html+css) ͱͯ͠UIຖʹಠཱʹઃఆ͢Δ͜ͱͰ ޓ͍ʹׯব͠ͳ͍UI͕࡞Γ͘͢ͳΔ ίϯϙʔωϯτͰఆٛ͞ΕΔϝιου جຊతʹॳظԽͱΠϕϯτͷΈͰ݁͢Δ Ϟσϧૢ࡞ઐ༻ͷΫϥεͰϩδοΫΛ σʔλߏઐ༻ͷΫϥεͰૢ࡞ରΛ ɹ=>componentʹඞཁͳϑΝΠϧΛू ɹɹɹ͢ΔΠϝʔδ
Slide 11
Slide 11 text
Angular2࣮ફϙΠϯτ ❖ angluar2webpackʹΑͬͯtranspileͰ͖ΔͷͰ,ϓϩμΫτͷҠ২ੑ͕ߴ͍ ڥຖʹઃఆϑΝΠϧ ΛมߋՄೳ ίϯύΠϧͷରϑΝ ΠϧͷઃఆͳͲ webpack.*.js(*=dev)Ͱ distʹϑΝΠϧग़ྗઌΛ ࢦఆ͍ͯ͠Δ
Slide 12
Slide 12 text
Angular2࣮ફϙΠϯτ ❖ testઃఆϑΝΠϧ࡞ͬͯ npm testͰ࣮ߦՄೳ karmaͱPhantomJSͷઃఆΛpackage.jsonͰઃఆͰ͖ΔͨΊ,e2eςετ ͱ͔؆୯ʹͰ͖ΔͬΆ͍Ͱ͢ɻ
Slide 13
Slide 13 text
Angular2࣮ફϙΠϯτ ❖ webpack ߏͰಈ͘Α͏ʹͨ͠ͷ
[email protected]
:tkow/angular2_qs_with_webpack.git ʢhttps://angular.io/docs/ts/latest/guide/webpack.html ɹΛͳͧͬͨͷʣ
Slide 14
Slide 14 text
Angular2ॴײ ❖ ྑ͔ͬͨ ❖ ComponentͱLayout͕ग़དྷΔͷͰ࠶ར༻ੑ,มߋʹ͓͚Δॊೈੑ͕ߴ͍ ❖ CSSͷ͕ྑ͍(શମͷCSSΛѲ͠ͳͯ͘ྑ͍Έ) ❖ ΫϥΠΞϯταΠυRouting͕ڧྗ ❖ TypeScriptͷImport ,Exportͷ͕ؔΘ͔Γ͍͢ͷͰJSϑΝΠϧΛૄ݁߹ʹ͍͢͠ ❖ Pipe͕͍͢͝ ❖ γʔϜϨεʹView͕ߋ৽͞ΕΔͷ͕͍͢͝ ❖ react-native + angular2 ͱ͍͏ຯʹ͍͢͝ϚϧνϓϥοτϑΥʔϜ։ൃϓϩδδΣΫ τ͕࣮ݱ͍ͯ͠Δ ❖ ng-cli͕͔ͳΓظͰ͖Δ(railsίϚϯυฒΈʹศརʹͳΓͦ͏)
Slide 15
Slide 15 text
Angular2ॴײ ❖ ਏ͔ͬͨ ❖ ֶशίετߴ͍(TypeScript,ಠࣗͷsyntax,ActiveRouter,Component,Decorator,ng~) ❖ ώΞυΩϡϝϯτʹhtmlcssΛॻ͚ΔͷͰԿߟ͑ͣʹ͏ͱSyntaxindent͕ࠅ͍͜ͱʹͳΔ (ϑΝΠϧΛ͢Δ͜ͱͰղܾ) ❖ *ngForͳͲ,λάͷதʹίʔυΛॻ͘ͷʹҧײ(׳Εͷʁ) ❖ ֊͚ͳͲͷઃఆΛࣗͰ͠ͳ͍ͱ,τϥϯεύΠϧϑΝΠϧ͕ࢄΒ͔Δ(webpackͰjsͷग़ྗઌΛ มߋग़དྷͨͷͰ,ࠓޙͷنԽCLIʹΑΔࣗಈ֊͚ʹظ ɻ) ❖ ͋͘·ͰframeworkͳͷͰ,طଘͷprojectʹ͙͢ʹಋೖͰ͖Δੑ͋·Γͳ͍ײ͕ͨ͡͠ (webpackng-cliͳͲͰಠཱͨ͠applicationͱͯ͠طଘͷϓϩμΫτʹͭͳ͙ͷ؆୯ͦ͏) ❖ ઃఆϑΝΠϧଟ͗͢(ng-cliʹࣗಈԽؤுͬͯཉ͍͠) ❖ έόϒέʔεʹҧײ ❖ ΠϕϯτϑοΫΞχϝʔγϣϯΛ͚Δํ๏Λ·ͩશʹѲͰ͖͍ͯͳ͍(CSSϝΠϯͱ͍͏ᷚ)
Slide 16
Slide 16 text
Angular2ॴײ ❖ ·ͱΊ ❖ ཧ͕͍͠jsϑΝΠϧΛΧϓηϧԽ͢ΔͨΊςετΓ͘͢ อकੑ͕ߴ͍ͷͰ৽نϓϩδΣΫτͰ͍͚ͬͯͦ͏ ❖ ng-clinpm,webpackͳͲΛಋೖ͢Δ͜ͱͰ,τϥϯεύΠϧ࣌ͷ ϑΝΠϧཧ؆୯ʹͳΓͦ͏ ❖ ϑΝΠϧͷมߋʹରͯ͠,ଈ࣌ԠͳͷͰσόοά͍͢͠ ❖ ΞϓϦέʔγϣϯͷن͕͋·Γେ͖͘ͳ͚ΕطଘͷίʔυΛ ॻ͖͑Δίετͷํ͕ߴͦ͏ ❖ ͜ΕΛͬͱԡ͑͞ͱ͚ͱ͍͏͜ͱ͕͋Εੋඇڭ͍͑ͯͩ͘͞ɻ
Slide 17
Slide 17 text
Angular2ॴײ ❖ ࠓޙظ͢Δࣄௐ͍ͨࣄ ❖ hamlͱ͔ςϯϓϨʔτΤϯδϯ͍͍ͨ(Emmet͑Δ ͚Ͳ) ❖ ઃఆϑΝΠϧͷgenerator͕ྑ͘ͳͬͯ΄͍͠ ❖ ࠓճtutorialΛऴΘΒͤΔ·Ͱ͔͠ग़དྷͳ͔ͬͨͷͰ,࣮ࡍ ʹϓϩμΫτΛ࡞ΔͷʹͬͯΈ͍ͨ