狠狠撸

狠狠撸Share a Scribd company logo
directiveの作り方 
????#RGLDNB
directive の作り方 @ 福岡 AngularJS 勉強会(第2回目)
自己紹介 
 ????#???????? 
 ?????5DLOV$QJXODU-6???? 
?????616???? 
 $QJXODU-6????????? 
 7ZLWWHURGLDNB
AngularJSの初心者に 
ありがちなこと 
 ?$QJXODU-6??????'20????? 
???????????? 
 ?GLUHFWLYH????????????? 
????????
诲颈谤别肠迟颈惫别、难しくないよ!
directiveとは 
 ?????+70/?????? 
 ?VFRSH????????'20????? 
 $QJXODU-6???'20?????? 
GLUHFWLYH??? 
 ???????????????
ロジックUI 
VFRSH? 
????? 
??????? 
6HUYLFH RQWUROOHU Directive +70/
組み込みdirective 
 $QJXODU-6??????????? 
 +70/???????????? 
QJFOLFNQJUHSHDWQJFRQWUROOHU? 
 +70/???????????? 
DVHOHFWVFULSW? 
 ????GLUHFWLYH???????$3,? 
????????
directiveの3つのかたち 
 ??PGLUHFWLYH!PGLUHFWLYH! 
 ??LQSXWPGLUHFWLYH ! 
 ???SFODVV PGLUHFWLYH!S! 
 GLUHFWLYH?????????????? 
??????????
directiveの処理が開始 
するまで 
 $QJXODU-6?+70/?????????? 
 ??????GLUHFWLYH??????? 
?????????????????? 
 ?????FRPSLOH?OLQN??? 
FRPSLOH?VFRSH???OLQN 
?????
directive の作り方 @ 福岡 AngularJS 勉強会(第2回目)
诲颈谤别肠迟颈惫别を定义する
YDUDSS DQJXODUPRGXOHDSS@
DSSGLUHFWLYHP'LUIXQFWLRQ
^ 
UHWXUQ^ 
???GLUHFWLYH??? 
` 
`
GLUHFWLYH????キャメルケース?? 
 +70/??my-directive?myDirective???? 
????
例1) 文字を赤くする 
directive
DSSGLUHFWLYHUHGIXQFWLRQ
^ 
UHWXUQ^ 
UHVWULFW$ 
OLQNIXQFWLRQVFRSHHOHPDWWUV
^ 
HOHPFVVFRORUUHG
` 
` 
`
restrict:GLUHFWLYH???????? 
$???(?????????????($ 
 link:?????????? 
VFRSH?????????????????? 
????M4XHU??
??????
使用例 
S!+HOORVSDQUHG!'LUHFWLYHVSDQ!S!
例2) テンプレートを 
使ったdirective
DSSGLUHFWLYHXVHUIXQFWLRQ
^ 
UHWXUQ^ 
UHVWULFW( 
VFRSH^ 
XVHU,QIR  
` 
UHSODFHWUXH 
WHPSODWH
? 
GLYFODVV XVHU!? 
LPJQJVUF ^^XVHU,QIRLFRQ``!? 
S!^^XVHU,QIRQDPH``S!? 
GLY!
 
` 
`
scope: {userInfo: =} 
?????VFRSH??XVHU,QIR????XVHULQIR?? 
??????????????? 
 replace: true 
????????????????????? 
 template: … 
+70/???????? 
WHPSODWH8UO????????+70/???????? 
???? 
UHSODFHWUXH???????????????

More Related Content

directive の作り方 @ 福岡 AngularJS 勉強会(第2回目)