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
一些 Angular 的最佳实践
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Bin Xin
July 01, 2015
Programming
100
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
一些 Angular 的最佳实践
Bin Xin
July 01, 2015
Other Decks in Programming
See All in Programming
Generative UI & AI-Assistants for Your Angular Solutions
manfredsteyer
PRO
0
140
AI時代の仕事技芸論〜ソフトウェア開発で「遊ぶように働く」職人的熟達のすすめ(スクフェス仙台 2026バージョン)
kuranuki
0
410
コンテキストの使い捨てをやめる — ビジネスルール駆動開発と miko —
ioki
0
270
Signal Forms: Details & Live Coding @enterJS 2026 in Mannheim
manfredsteyer
PRO
0
220
Observability in Practice:Grafana 與 Edge Device SRE 的那些事
blueswen
0
190
使用 Meilisearch 建立新聞搜尋工具
johnroyer
0
100
AI がコードを書く時代における新卒エンジニアの仕事風景 (2026) / New Graduate Engineers in the Era of AI Coding (2026)
sushichan044
0
200
トークンをケチるな、設計しろ:GitHub Copilotを賢く使うコンテキスト戦略
ochtum
0
300
Vite+ Unified Toolchain for the Web
naokihaba
0
690
Vue × Nuxt × Oxc どこまで使える?実運用の現在地
andpad
0
360
ローカルLLMでどこまでコードが書けるか -縮小版 / How much code can be written on a local LLM Shortened
kishida
2
180
Webフレームワークの ベンチマークについて
yusukebe
0
200
Featured
See All Featured
More Than Pixels: Becoming A User Experience Designer
marktimemedia
3
460
Google's AI Overviews - The New Search
badams
0
1.1k
Agile that works and the tools we love
rasmusluckow
331
22k
Groundhog Day: Seeking Process in Gaming for Health
codingconduct
0
240
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
330
エンジニアに許された特別な時間の終わり
watany
107
250k
Lightning Talk: Beautiful Slides for Beginners
inesmontani
PRO
2
600
Thoughts on Productivity
jonyablonski
76
5.2k
AI in Enterprises - Java and Open Source to the Rescue
ivargrimstad
0
1.4k
Stewardship and Sustainability of Urban and Community Forests
pwiseman
0
250
The agentic SEO stack - context over prompts
schlessera
0
840
How STYLIGHT went responsive
nonsquared
100
6.2k
Transcript
ӞԶ Angular ጱ๋֯ਫ ᪢ 2015.7 1
ֵአ ControllerAs դ๊ $scope <script> angular.module('app', []) .controller('FooCtrl', function ()
{ this.foo = 'this is foo' }) </script> <div ng-app="app" ng-controller="FooCtrl as ctrl"> {{ ctrl.foo }} </div> 2015.7 2
$scope.ctrl = new Ctrl see 2015.7 3
Pros • ӧᵱᥝׁᩢ $scope ဳف • හഝᬰᛔݷҁݷᑮᳵ҂҅عݒᰁ٫ᑱ • ݢզعӞԶଉᥠጱᔩᔊҁైአ$scope.$watch҂ •
ฃၥᦶ • ᶎݻ๚ҁAngular2҂ 2015.7 4
ࣁ Directive Ӥֵአ module.directive('fooBar', function () { return { scope:
{}, template: '{{ ctrl.foo }}', controllerAs: 'ctrl', controller: function () { this.foo = 'this is foobar directive' } } }) 2015.7 5
Directive ጱᳯ᷌ module.directive('fooBar', function () { return { scope: {
data: '=' }, template: '{{ ctrl.foo }} {{ ctrl.data.xx }}', controllerAs: 'ctrl', controller: function ($scope) { this.foo = 'this is foobar directive' // handle data var self = this $scope.$watch('data', function (data) { self.data = data }) } } }) 2015.7 6
bindToController!! 2015.7 7
ֵአ Directive ᕟᕢᶭᶎ 2015.7 8
2015.7 9
Pros • ᕟկ۸ • ᶎݻ๚ҁAngular2҂ 2015.7 10
عֵአ $scope ᱾ᬰᤈᕟկԏᳵጱԻ ᭗ᬦֵአ Serviceҁහഝ҂ ᘏ eventsҁ᭗ᦔ҂ 2015.7 11
$scope.$broadcast('addTask', list) $scope.$emit('createdTask', task) see 2015.7 12
Pros • ܔݻහഝၞ • flux • ӧᵱᥝփ handler҅$scope Ԟๅےଗٳ •
<foo on-save="ctrl.create(foo)"/> 2015.7 13
Router ng-click="router.forward('/folder')" 2015.7 14
href="/folder" see 2015.7 15
Pros • ݢᦢᳯ • ຽٵ۸ 2015.7 16
ཛྷࣘဳف // directives/foo.js return function ($scope, $timeout) { return {
scope: {} template: 'xxx' link: function () {} } } // module.js module.directive('foo', ['$scope', '$timeout', foo]) 2015.7 17
// directives/foo.js return ['$scope', '$timeout', function ($scope, $timeout) { return
{ scope: {} template: 'xxx' link: function () {} } }] // module.js module.directive('foo', foo) 2015.7 18
// directives/foo.js module.directive('foo', ['$scope', '$timeout', function ($scope, $timeout) { return
{ scope: {} template: 'xxx' link: function () {} } }]) 2015.7 19
Extra: token vs cookie 2015.7 20
2015.7 21
Pros • CORS • Stateless • ຽٵ۸ https://tools.ietf.org/html/rfc7519 • قᒒঅ
• ฃၥᦶ see 2015.7 22
Thanks • http://www.benlesh.com/2013/10/title.html • http://blog.thoughtram.io/angularjs/2015/01/02/exploring- angular-1.3-bindToController.html • http://jwt.io • https://auth0.com/blog/2014/01/07/angularjs-
authentication-with-cookies-vs-token/ 2015.7 23