Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
一些 Angular 的最佳实践
Search
Bin Xin
July 01, 2015
Programming
110
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
アクセシビリティから考える情報設計
high_g_engineer
0
330
Webの地図
yosuke_furukawa
PRO
3
3.1k
Seeing Through Serverless: Observability for AWS Lambda with ADOT and CloudWatch Application Signals
seike460
PRO
1
130
思考垂れ流し開発 ~音声入力 × AIエージェント × 開発ハーネスによる試行錯誤~
npostring
0
990
Hello, Hiroshima Geospatial Data! — Exploring DoboX with Python
ra0kley
0
180
一参加者から『中の人』へ 〜全通PHPerがブースに立って学んだ、カンファレンスを100倍楽しむコツ〜
wp_daisuke
0
130
変化を抱擁するドキュメントの作り方 - ビジネスルール駆動開発がもたらす、コードとの新しい関係
ioki
2
120
【高い買い物LT会】初任給で話題の国産フィジカルAIを買った話
akagami
PRO
0
100
20260828_品質と開発生産性を両立させる、AI時代のE2Eテストの考え方
magicpod
0
170
まだ間に合う!今年の夏こそSchemeのマクロ展開器を完全理解!
omasanori
0
640
不幸な GC
chencmd
0
890
AgentCore CLI で進化した AWS での AI エージェントの作り方 : 必要な機能を必要な時に
icoxfog417
PRO
2
210
Featured
See All Featured
The Curious Case for Waylosing
cassininazir
1
500
Odyssey Design
rkendrick25
PRO
2
800
Marketing to machines
jonoalderson
1
5.8k
Six Lessons from altMBA
skipperchong
29
4.5k
What Being in a Rock Band Can Teach Us About Real World SEO
427marketing
0
1.1k
SEOcharity - Dark patterns in SEO and UX: How to avoid them and build a more ethical web
sarafernandez
0
270
[SF Ruby Conf 2025] Rails X
palkan
2
1.4k
How to optimise 3,500 product descriptions for ecommerce in one day using ChatGPT
katarinadahlin
PRO
2
3.8k
Design of three-dimensional binary manipulators for pick-and-place task avoiding obstacles (IECON2024)
konakalab
0
580
Claude Code のすすめ
schroneko
67
230k
Bridging the Design Gap: How Collaborative Modelling removes blockers to flow between stakeholders and teams @FastFlow conf
baasie
0
690
Prompt Engineering for Job Search
mfonobong
0
450
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