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
15-437 AngularJS
Search
ThierrySans
February 09, 2016
Programming
140
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
15-437 AngularJS
ThierrySans
February 09, 2016
More Decks by ThierrySans
See All by ThierrySans
CSCD27 Social Engineering
thierrysans
0
260
CSCD27 Web Security
thierrysans
0
450
CSCD27 Malicious Software
thierrysans
0
400
CSCD27 Protection
thierrysans
0
510
CSCD27 System Insecurity
thierrysans
0
440
CSCD27 Human Authentication
thierrysans
0
370
CSCD27 Network security
thierrysans
0
580
CSCD27 Network (in)security
thierrysans
0
570
CSCD27 Cryptography Protocols
thierrysans
0
720
Other Decks in Programming
See All in Programming
ふつうのFeature Flag実践入門
irof
8
4.2k
コンテキストの使い捨てをやめる — ビジネスルール駆動開発と miko —
ioki
0
230
メソッドのジェネリクスでGoの夢は広がるか? / Kyoto.go #65
utgwkk
3
930
dRuby over BLE
makicamel
2
390
並列実装の現場、2ヶ月間実務でAIを使い倒したAIもPCも私も限界が近い
ming_ayami
0
130
AIで効率化できた業務・日常
ochtum
0
150
AIだと陥りがちなJakarta EE最新技術への移行時の落とし穴と解決策
tnagao7
0
120
Datadog × OpenTelemetry 入門と実践のあいだ
kn_to_maxpno
1
180
PHPで使える日時の表現と、その知り方 #frontend_phpcon_do
o0h
PRO
0
260
Language Server 使ってる? 〜VSCode と Zed の場合〜 / Are you using a Language Server? ~For VS Code and Zed~
handlename
0
800
さぁV100、メモリをお食べ・・・
nilpe
0
150
Vite+ Unified Toolchain for the Web
naokihaba
0
340
Featured
See All Featured
So, you think you're a good person
axbom
PRO
2
2.1k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.5k
How To Stay Up To Date on Web Technology
chriscoyier
790
250k
jQuery: Nuts, Bolts and Bling
dougneiner
66
8.5k
SERP Conf. Vienna - Web Accessibility: Optimizing for Inclusivity and SEO
sarafernandez
2
1.5k
Leading Effective Engineering Teams in the AI Era
addyosmani
9
2.1k
Statistics for Hackers
jakevdp
799
230k
Fashionably flexible responsive web design (full day workshop)
malarkey
408
66k
Agile Actions for Facilitating Distributed Teams - ADO2019
mkilby
0
210
Writing Fast Ruby
sferik
630
63k
Marketing to machines
jonoalderson
1
5.5k
Designing for Performance
lara
611
70k
Transcript
AngularJS Thierry Sans
Different approaches Binding between the DOM and the javascript code
jQuery-like Using DOM selectors AngularJS Using Angular directives
Application
ng-app directive <!DOCTYPE html> <html ng-app="simpsonsApp"> <head> <script src="bower_components/angular/angular.min.js"></script> <script
src="app/simpsonsapp.js"></script> </head> ... /index.html /app/simpsonsApp.json var app = angular.module('simpsonsApp',[]);
Controller
ng-controller directive <body ng-controller="simpsonsController as simpsons"> <header> <h1>{{simpsons.title}}</h1> <div ng-click="simpsons.foo()"></div>
</header> /index.html /app/simpsonsApp.json app.controller('simpsonsController',function(){ this.data = “Hello World!”; this.foo = function(){ this.data = “The Simpsons”; }; )};
ng-show (ng-hide) directive <header> <h1>The Simpsons</h1> <div id="admin_button" ng-click="simpsons.toggle()"></div> </header>
<div id="add_simpson_form_wrapper" ng-show="simpsons.show_form"> <form class="complex_form" id="add_simpson_form"> ... </form> </div> /index.html /app/simpsonsApp.json app.controller('simpsonsController',function(){ show_form = false; this.toggle = function(){ this.show_form = ! this.show_form; }; )};
ng-repeat directive <div class="entry" ng-repeat="img in simpsons.data"> <div class=“img_box"> <img
ng-src="{{img.img_url}}" alt=“{{img.firstname}}"/> </div> <div class=“firstname”> <a href=“{{img.w_url}}">{{img.firstname}}</a> </div> <div class="down_button vote_button">{{img.down_vote}}</div> <div class="up_button vote_button">{{img.up_vote}}</div> </div> /index.html /app/simpsonsApp.json this.data = [ {"firstname": “Bart", ...}, {"firstname": “Lisa”, ...} ];
Forms
ng-model and ng-submit directive /app/simpsonsApp.json app.controller('simpsonsController',function($scope){ this.character = {}; this.add_simpson
= function(){ this.character.up_vote=0; this.character.down_vote=0; this.data.push(this.character); this.character = {}; $scope.add_simpson_form.$setPristine(); };}); <form ng-submit=“simpsons.add_simpson()”> <div class="form_title">Add a Simpson</div> <input type="name" ng-model="simpsons.character.firstname"/> <input type="url" ng-model="simpsons.character.img_url"/> <input type="url" ng-model="simpsons.character.w_url"/> <input type="submit" class="btn" value="Add"/> </form> /index.html
Ajax
$ajax /app/simpsonsApp.json app.controller('simpsonsController',function($http){ this.data = []; var controller = this;
$http.get('api/simpsons.json') .success(function(data,status){ controller.data = data; }) .error(function(error,status){ }); });
Service (Model)
Routing