Submit Search
Upload
活動報告5 ~簡単なディレクティブを作る~
•
Download as PPTX, PDF
•
0 likes
•
508 views
V
vx-pc-club
Follow
活動報告5 ~簡単なディレクティブを作る~
Read less
Read more
Engineering
Report
Share
Report
Share
1 of 11
Download now
Recommended
活動報告7 d&dなディレクティブを作る-
活動報告7 d&dなディレクティブを作る-
vx-pc-club
活動報告6 オートコンプリート的なディレクティブを作る-
活動報告6 オートコンプリート的なディレクティブを作る-
vx-pc-club
cochica
cochica
Hiroki Yoshida
Azure ml
Azure ml
vx-pc-club
I phoneアプリ入門 第4回
I phoneアプリ入門 第4回
Sachiko Kajishima
Bing autosuggest apiを使ってみた
Bing autosuggest apiを使ってみた
vx-pc-club
Azure text analytics apiつかってみる
Azure text analytics apiつかってみる
vx-pc-club
Azure app serviceの環境構築 php7とpdo-sqlsrvを使う方法-
Azure app serviceの環境構築 php7とpdo-sqlsrvを使う方法-
vx-pc-club
Recommended
活動報告7 d&dなディレクティブを作る-
活動報告7 d&dなディレクティブを作る-
vx-pc-club
活動報告6 オートコンプリート的なディレクティブを作る-
活動報告6 オートコンプリート的なディレクティブを作る-
vx-pc-club
cochica
cochica
Hiroki Yoshida
Azure ml
Azure ml
vx-pc-club
I phoneアプリ入門 第4回
I phoneアプリ入門 第4回
Sachiko Kajishima
Bing autosuggest apiを使ってみた
Bing autosuggest apiを使ってみた
vx-pc-club
Azure text analytics apiつかってみる
Azure text analytics apiつかってみる
vx-pc-club
Azure app serviceの環境構築 php7とpdo-sqlsrvを使う方法-
Azure app serviceの環境構築 php7とpdo-sqlsrvを使う方法-
vx-pc-club
2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
Marius Sescu
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
Expeed Software
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
Pixeldarts
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
ThinkNow
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
marketingartwork
Skeleton Culture Code
Skeleton Culture Code
Skeleton Technologies
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
Neil Kimberley
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
contently
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
Albert Qian
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
Search Engine Journal
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
SpeakerHub
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
Clark Boyd
Getting into the tech field. what next
Getting into the tech field. what next
Tessa Mero
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Lily Ray
How to have difficult conversations
How to have difficult conversations
Rajiv Jayarajah, MAppComm, ACC
Introduction to Data Science
Introduction to Data Science
Christy Abraham Joy
Time Management & Productivity - Best Practices
Time Management & Productivity - Best Practices
Vit Horky
The six step guide to practical project management
The six step guide to practical project management
MindGenius
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
RachelPearson36
More Related Content
Featured
2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
Marius Sescu
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
Expeed Software
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
Pixeldarts
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
ThinkNow
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
marketingartwork
Skeleton Culture Code
Skeleton Culture Code
Skeleton Technologies
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
Neil Kimberley
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
contently
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
Albert Qian
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
Search Engine Journal
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
SpeakerHub
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
Clark Boyd
Getting into the tech field. what next
Getting into the tech field. what next
Tessa Mero
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Lily Ray
How to have difficult conversations
How to have difficult conversations
Rajiv Jayarajah, MAppComm, ACC
Introduction to Data Science
Introduction to Data Science
Christy Abraham Joy
Time Management & Productivity - Best Practices
Time Management & Productivity - Best Practices
Vit Horky
The six step guide to practical project management
The six step guide to practical project management
MindGenius
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
RachelPearson36
Featured
(20)
2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
Skeleton Culture Code
Skeleton Culture Code
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
Getting into the tech field. what next
Getting into the tech field. what next
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
How to have difficult conversations
How to have difficult conversations
Introduction to Data Science
Introduction to Data Science
Time Management & Productivity - Best Practices
Time Management & Productivity - Best Practices
The six step guide to practical project management
The six step guide to practical project management
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
活動報告5 ~簡単なディレクティブを作る~
1.
パソコン部活動報告 2015/03/31 最新の技術をとりあえず試 してみることを目的とした 部です。
2.
2015/03月活動内容 1. angular.js1.3系を利用して再利用可能なディレクティブを作成する Look at
me mom...dad and I are having so much fun!
3.
1.概要 1. 今回作る予定のディレクティブ angularではDom要素の変更はdirectiveに任せる思想があるので、クリックした要素を強調してどれがおさせたかわかるよう になるディレクティブを作成する。 最終的にはクリックしたObject情報を特定できるようにする。 完成イメージ化こちら ちょっとわかりにくいけど、クリックすると灰色になる。
4.
2.ディレクティブを考える 1. restrict まずは、Directiveの運用方法を何にするかを考えてみる。 指定できるオプションは4つ。 いろいろと使いまわせるものにしたいのと、きっとリピート処理と一緒に使うことになるので、Aにすることにする。 A 属性名として利用可能 E
要素名として利用可能 C クラス名として利用可能 M コメントとして利用可能
5.
2.ディレクティブを考える 2. scope 次はscopeの生成方法を考えてみる。 再利用を前提としたdirectiveは分離スコープにするべきとangularの偉い人が言ってたんで、分離スコープにする。 scopeに指定できるオプションは以下の3つ。 scopeの共有ってのは、指定されているコントローラーで利用されているscope(親scope)を共有すること。 派生したscopeを生成ってのは、指定されているコントローラーのscopeに属するscopeになるってこと。 つまり、scopeに対してdirectiveから直接アクセスできちゃうし、コントローラーで指定されたscopeを指定するってこと は そのscopeに依存しちゃう。 だからscopeを分離することで独立性を高めるわけです。 false 利用箇所のscopeを共有 true
利用箇所のscopeから派生したscopeを生成 オブジェクトリテラ ル 分離スコープを生成
6.
2.ディレクティブを考える 2. scope 分離スコープにするんだけど、利用するスコープのメンバにどういった属性を指定するかを考える。 指定できるのは以下の3つ。 想定する使い方はリピートされた要素に対して属性として指定するんだから、リピート要素をデータバインディングすれ ばOK。 ここまでをコーディングするとこんな感じ 。 pushDirectiveってのは、このdirectiveの名称。 pushInfoがこのdirective内でアクセスするための 名称になって、infoがこのdirectiveを指定した要素側 でバインドする時に指定する名称。 @ 文字列として結びつける =
データバインディングとして結びつける & functionとして結びつける
7.
2.ディレクティブを考える 3. link んじゃ、実際に指定された場合のことを考えてみる。 まず、読み込まれたら該当要素にclickイベントを設定しないとだめだよね。 clickイベントのfunctionで要素のCSSを変更すればOKだから、簡単にできそう。 そこで使うのがlink関数。こいつが実行される時にはscopeが生成されてる。 パラメータは全部で5つあるけど、今回は↓の3つだけで大丈夫。 scope directiveのscope element
指定された要素 attrs 属性
8.
2.ディレクティブを考える 3. link ソースコードはこんな感じになる。
9.
2.ディレクティブを考える 3. link 最後に分離スコープにクリックされた要素であることを設定する処理を追加する。 赤枠が追加した部分。 バインドされたオブジェクトにメンバを追加して どれが押されたかがわかるようにした。 押されたのもの抽出は、コントローラーかサービス 側の仕事ということで。。。
10.
3.ディレクティブを使う 1. HTMLに指定する 最後に、作ったディレクティブを使ってみる。
11.
4.最後 1. HTMLに指定する directiveには今回指定しなかった、オプションがまだまだある。 direcitveを作るうえでは、templeteオプション、templeteUrlオプション、compile関数は抑えておいたほうがいい。 あー、unityでクソゲー作りたくなってきた。
Editor's Notes
Image Sources:http://www.flickr.com/photos/cat_bus/2436839379/sizes/l/http://www.flickr.com/photos/chippenziedeutch/1338350448/sizes/l/http://www.flickr.com/photos/17625613@N00/63534223/sizes/o/http://www.flickr.com/photos/andy_bernay-roman/740526711/sizes/o/http://www.flickr.com/photos/criminalintent/2246696077/sizes/l/http://www.flickr.com/photos/criminalintent/2300328819/sizes/l/in/set-72157603816609718/http://www.flickr.com/photos/criminalintent/2344482203/sizes/l/in/set-72157603816609718/http://www.flickr.com/photos/billward/110319298/sizes/o/http://www.flickr.com/photos/ginamig/2283868571/sizes/l/http://www.flickr.com/photos/cochese/1388690893/sizes/o/
Download now