Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Speaker Deck
PRO
Sign in
Sign up for free
Powerful Applications with AngularJS
Anna Filina
PRO
May 30, 2015
Programming
0
100
Powerful Applications with AngularJS
Anna Filina
PRO
May 30, 2015
Tweet
Share
More Decks by Anna Filina
See All by Anna Filina
Writing Testable Symfony Apps
afilina
PRO
0
82
Upgrading Legacy to the Latest PHP Version
afilina
PRO
0
140
Avoid Costly Framework Upgrades
afilina
PRO
2
1.3k
Fantastic Bugs and How to Avoid Them
afilina
PRO
1
780
Adding Tests to Untestable Legacy Code
afilina
PRO
4
860
You Don't Need More Developers
afilina
PRO
5
1.2k
Fantastic Bugs and How to Avoid Them
afilina
PRO
0
170
Ship 10 Times Faster With These Designs
afilina
PRO
0
420
Effortless Software Development
afilina
PRO
1
390
Other Decks in Programming
See All in Programming
NGK2023S - OCaml最高! スマホ開発にも使えちゃう?!
haochenxie
0
120
Makuakeの認証基盤とRe-Architectureチーム
bmf_san
0
650
OIDC仕様に準拠した Makuake ID連携基盤構築の裏側
ymtdzzz
0
610
Swift Observation
shiz
4
300
Remote SSHで行うVS Codeリモートホスト開発とトラブルシューティング
smt7174
1
520
新卒でサービス立ち上げから Hasuraを使って3年経った振り返り
yutorin
0
240
AWSとCPUのムフフな関係
cmdemura
0
480
domain層のモジュール化 / MoT TechTalk #15
mot_techtalk
0
150
LIFFで動く割り勘アプリTATEKAをリリースしてみた話
inoue2002
0
270
Form実装基本を学び直してみた
hyugatsukui
0
250
CDKでValidationする本当の方法 / cdk-validation
gotok365
1
260
レガシーフレームワークからの移行
ug
0
130
Featured
See All Featured
Debugging Ruby Performance
tmm1
67
11k
The Invisible Side of Design
smashingmag
292
48k
Fireside Chat
paigeccino
16
1.9k
Learning to Love Humans: Emotional Interface Design
aarron
263
38k
The MySQL Ecosystem @ GitHub 2015
samlambert
240
11k
Producing Creativity
orderedlist
PRO
335
38k
Designing with Data
zakiwarfel
91
4.2k
Rails Girls Zürich Keynote
gr2m
87
12k
4 Signs Your Business is Dying
shpigford
171
20k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
349
27k
The Invisible Customer
myddelton
113
12k
Done Done
chrislema
178
15k
Transcript
foolab.ca | @foolabca Powerful Applications with AngularJS CakeFest, New York
- May 30, 2015
Anna Filina • Developer • Problem solver • Coach •
Advisor 2
Objectives • More advanced front-end. • Maintainable code with fewer
bugs. • AngularJS site in 30 minutes. • Inspire to build great apps. 3
The problem with JS • Messy content updates. • HTML
tangled with JS. • Hard to keep everything in sync. 4
AngularJS • Automatic content updates. • HTML separated from JS
logic. • Everything automatically in sync. 5
Data flow 7 products selectedProduct
HTML <html ng-app> <head> <script src="angular.js"></script> <script src="app.js"></script> </head> <body>
<div ng-controller="ProductsCtrl"> </div> </body> </html> 8
Inside the DIV <div ng-controller="ProductsCtrl"> <div ng-repeat="item in products"> <img
ng-src="{{ item.image }}"> <p>{{ item.name }}</p> </div> </div> 9
Details <div ng-show="selectedProduct"> <h2>{{ selectedProduct.name }}</h2> </div> [...] <div ng-repeat="item
in products"> <a href="" ng-click="showDetails(item)"></a> </div> 10
Javascript function ProductsCtrl($scope) { $scope.products = [ { "id": "product-1",
"name": "Skyrim", "description": "Short product description.", "image": "http:...", "price": 19.99, "stock": 10 }]; $scope.showDetails = function(item) { $scope.selectedProduct = item; }; }; 11
Data flow 12 $scope.products $scope.showDetails $scope.selectedProduct <div ng-repeat="item in products">
<a ng-click="showDetails(item)"> <h2>{{ selectedProduct.name }}</h2>
Directives (ng-) 13 ng-show="selectedProduct" ng-class="{nostock: selectedProduct.stock == 0 }"
Data flow 15 maxPrice updateResults
HTML <input ng-model="minPrice" ng-change="updateResults()"> <div ng-repeat="item in products" ng-class="{dim: item.hidden
== true}"> 16
Javascript $scope.query = ''; $scope.minPrice = 1; $scope.maxPrice = 20;
$scope.updateResults = function() { for (var i = 0; i < $scope.products.length; i++) { var product = $scope.products[i]; product.hidden = true; [...] if (matchesQuery && matchesPrice) { product.hidden = false; } }; } 17
Directives (ng-) 18 <input ng-model="maxPrice" ng-change="updateResults()"> $scope.maxPrice $scope.updateResults = function()
{} <div ng-class="{dim: item.hidden == true}">
HTML <html ng-app="myApp"> [...] <script src="angular.js"></script> <script src="angular-resource.js"></script> 20
Javascript var app = angular.module('myApp', ['ngResource']); app.controller('ProductsCtrl', function($scope, $resource) {
var url = 'http://api.shop.dev/v1.0/products'; $resource(url).get({}, function(response) { $scope.products = response.data; }); }); 21
None
Services • Development: PHP, JS, etc. • Fix problems: bugs,
performance, etc. • Workshops: AngularJS, testing, Symfony, etc. • Advisor: testing strategy, architecture, etc. 25
@afilina afilina.com