SlideShare ist ein Scribd-Unternehmen logo
1 von 46
Downloaden Sie, um offline zu lesen
Shaping Up with Angular
Level 1: Getting Started
What you need to know
Must know Not so important
Nice to know
Automated Testing
BDD - Behavior Driven Development
TDD - Test Driven Development
etc
HTML & CSS
JavaScript
jQuery
Ruby on Rails
Python, PHP, etc
Databases
Why Angular?
If you’re using JavaScript to create a dynamic website,
Angular is a good choice.
‱ Angular helps you organize your JavaScript
‱ Angular helps create responsive (as in fast) websites.
‱ Angular plays well with jQuery
‱ Angular is easy to test
Traditional Page-Refresh
Screencast: Request-Response Application
NOTE: Time between user ‹
interaction and response.
Web Server
HTML JavaScript
Response with Webpage & Assets
Web Browser
URL Request to server
Response with Webpage & Assets
User clicks on link, new Request HTML JavaScript
Browser loads up
entire webpage.
Browser loads up
entire webpage.
Screencast: Request-Response Application
NOTE: Note how responsive the page is
A “responsive” website using Angular
Web Server
Response with Webpage & Assets
Web Browser
URL Request to server
Response with JSON Data
User clicks on link, new Request
HTML JavaScript
DATA
Browser loads up
entire webpage.
Data is loaded into
existing page.
Modern API-Driven Application
HTML Browser
App
Data
Source
Mobile
App
Developers
Server
API
A client-side JavaScript Framework for adding interactivity to HTML.
app.js
index.html
How do we tell our HTML when to trigger our JavaScript?
<!DOCTYPE html>‹
<html>‹
<body‹
. . .
</body>‹
</html>
function Store‹
alert('Welcome, Gregg!');‹
}‹
(){
>
What is Angular JS?
<!DOCTYPE html>‹
<html>‹
<body‹
. . .
</body>‹
</html>
app.js
function Store‹
alert('Welcome, Gregg!');‹
}‹
A Directive is a marker on a HTML tag that tells Angular to run or reference
some JavaScript code.
Directives
Name of
function to call
index.html
Controller(){
ng-controller="StoreController">
The Flatlanders Store!
Screencast: Flatlanders Store
Fully Functional
Download AngularJS http://angularjs.org/
We’ll need angular.min.js
Downloading the libraries
Download Twitter Bootstrap http://getbootstrap.com/
We’ll need bootstrap.min.css
<!DOCTYPE html>‹
<html>‹
<head>‹
<link rel="stylesheet" type="text/css" href="bootstrap.min.css" />‹
</head>‹
<body>‹
<script type="text/javascript" src="angular.min.js"></script>‹
</body>‹
</html>
Getting Started
index.html
Twitter Bootstrap
AngularJS
Modules
‱ Where we write pieces of our Angular application.
‱ Makes our code more maintainable, testable, and readable.
‱ Where we define dependencies for our app.
Modules can use other Modules...
Creating Our First Module
Dependencies
Other libraries we might need. ‹
We have none... for now

Application
Name
AngularJS
var app = angular.module('store', [ ]);
Including Our Module
var app = angular.module('store', [ ]); app.js
index.html
<!DOCTYPE html>‹
<html>‹
<head>‹
<link rel="stylesheet" type="text/css" href="bootstrap.min.css" />‹
</head>‹
<body>‹
<script type="text/javascript" src="angular.min.js"></script>
<script type="text/javascript" src="app.js"></script>
</body>‹
</html>
Including Our Module
var app = angular.module('store', [ ]); app.js
<!DOCTYPE html>‹
<html ng-app="store">‹
<head>‹
<link rel="stylesheet" type="text/css" href="bootstrap.min.css" />‹
</head>‹
<body>‹
<script type="text/javascript" src="angular.min.js"></script>‹
<script type="text/javascript" src="app.js"></script>‹
</body>‹
</html>
Run this module
when the document
loads.
index.html
Allow you to insert dynamic values into your HTML.
Expressions
Numerical Operations
evaluates to
String Operations
evaluates to
+ More Operations:
http://docs.angularjs.org/guide/expression
<p>‹
I am {{4 + 6}}‹
</p>
<p>‹
{{"hello" + " you"}}‹
</p>
<p>‹
I am 10‹
</p>
<p>‹
hello you‹
</p>‹
Including Our Module
var app = angular.module('store', [ ]); app.js
<!DOCTYPE html>‹
<html ng-app="store">‹
<head>‹
<link rel="stylesheet" type="text/css" href="bootstrap.min.css" />‹
</head>‹
<body>‹
<script type="text/javascript" src="angular.min.js"></script>‹
<script type="text/javascript" src="app.js"></script>‹
<p>{{"hello" + " you"}}</p>
</body>‹
</html> index.html
Challenges
Working With Data
...just a simple
object we want to
print to the page.
var gem = {‹
name: 'Dodecahedron',‹
price: 2.95,‹
description: '. . .',‹
}.
Controllers
app.js
Notice that controller is attached to (inside) our app.
Controllers are where we define our app’s behavior by defining
functions and values.
Wrapping your Javascript
in a closure is a good habit!
var gem = {‹
name: 'Dodecahedron',‹
price: 2.95,‹
description: '. . .',‹
}.
})();
(function(){‹
var app = angular.module('store', [ ]);
app.controller('StoreController', function(){‹
‹
});
Storing Data Inside the Controller
app.js
Now how do we
print out this
data inside our
webpage?
this.product = gem;
var gem = {‹
name: 'Dodecahedron',‹
price: 2.95,‹
description: '. . .',‹
}.
})();
(function(){‹
var app = angular.module('store', [ ]);
app.controller('StoreController', function(){‹
‹
});
<!DOCTYPE html>‹
<html ng-app="store">‹
<head>‹
<link rel="stylesheet" type="text/css" href="bootstrap.min.css" />‹
</head>‹
!
!
!
!
!
!
!
!
</html>‹
<body>‹
<div>‹
<h1> Product Name </h1>‹
<h2> $Product Price </h2>‹
<p> Product Description </p>‹
</div>‹
<script type="text/javascript" src="angular.min.js"></script>‹
<script type="text/javascript" src="app.js"></script>‹
</body>
Our Current HTML
Let’s load our data into
this part of the page.
}
index.html
<body>‹
<div>‹
<h1> Product Name </h1>‹
<h2> $Product Price </h2>‹
<p> Product Description </p>‹
</div>‹
<script type="text/javascript" src="angular.min.js"></script>‹
<script type="text/javascript" src="app.js"></script>‹
</body>
(function(){‹
var app = angular.module('store', [ ]);‹
‹
app.controller('StoreController', function(){‹
this.product = gem;
});
. . .
})(); app.js
index.html
Attaching the Controller
<body>‹
<div ng-controller="StoreController as store">‹
<h1> Product Name </h1>‹
<h2> $Product Price </h2>‹
<p> Product Description </p>‹
</div>‹
<script type="text/javascript" src="angular.min.js"></script>‹
<script type="text/javascript" src="app.js"></script>‹
</body>
Attaching the Controller
(function(){‹
var app = angular.module('store', [ ]);‹
‹
app.controller('StoreController', function(){‹
this.product = gem;
});
. . .
})(); app.js
index.html
Controller name Alias
Directive
<body>‹
<div ng-controller="StoreController as store">‹
!
!
</div>‹
<script type="text/javascript" src="angular.min.js"></script>‹
<script type="text/javascript" src="app.js"></script>‹
</body> index.html
Displaying Our First Product
(function(){‹
var app = angular.module('store', [ ]);‹
‹
app.controller('StoreController', function(){‹
this.product = gem;
});
. . .
})(); app.js
<h1> {{store.product.name}} </h1>‹
<h2> ${{store.product.price}} </h2>‹
<p> {{store.product.description}} </p>
Understanding Scope
Would never print a
value!
The scope of
the Controller
is only inside
here...
}
{{store.product.name}}
<h1> {{store.product.name}} </h1>‹
<h2> ${{store.product.price}} </h2>‹
<p> {{store.product.description}} </p>
<body>‹
<div ng-controller="StoreController as store">‹
!
!
</div>‹
<script type="text/javascript" src="angular.min.js"></script>‹
<script type="text/javascript" src="app.js"></script>‹
</body>
Challenges
</div>‹
<script type="text/javascript" src="angular.min.js"></script>‹
<script type="text/javascript" src="app.js"></script>‹
</body>
<body ng-controller="StoreController as store">‹
<div>‹
<h1> {{store.product.name}} </h1>‹
<h2> ${{store.product.price}} </h2>‹
<p> {{store.product.description}} </p>
Adding A Button
index.html
var gem = {‹
name: 'Dodecahedron',‹
price: 2.95,‹
description: '. . .',
}.
var gem = {‹
name: 'Dodecahedron',‹
price: 2.95,‹
description: '. . .',
}.
canPurchase: false
</div>‹
<script type="text/javascript" src="angular.min.js"></script>‹
<script type="text/javascript" src="app.js"></script>‹
</body>
Adding A Button
index.html
<button
How can we
only show
this button...
...when this is true?
Directives to
the rescue!
<body ng-controller="StoreController as store">‹
<div>‹
<h1> {{store.product.name}} </h1>‹
<h2> ${{store.product.price}} </h2>‹
<p> {{store.product.description}} </p>
> Add to Cart </button>
var gem = {‹
name: 'Dodecahedron',‹
price: 2.95,‹
description: '. . .',
}.
canPurchase: false
</div>‹
<script type="text/javascript" src="angular.min.js"></script>‹
<script type="text/javascript" src="app.js"></script>‹
</body>
NgShow Directive
index.html
<button
<body ng-controller="StoreController as store">‹
<div>‹
<h1> {{store.product.name}} </h1>‹
<h2> ${{store.product.price}} </h2>‹
<p> {{store.product.description}} </p>
ng-show="store.product.canPurchase"> Add to Cart </button>
Will only show the element if the
value of the Expression is
true.
</div>‹
<script type="text/javascript" src="angular.min.js"></script>‹
<script type="text/javascript" src="app.js"></script>‹
</body> index.html
<button
<body ng-controller="StoreController as store">‹
<div‹
<h1> {{store.product.name}} </h1>‹
<h2> ${{store.product.price}} </h2>‹
<p> {{store.product.description}} </p>
ng-show="store.product.canPurchase"> Add to Cart </button>
NgHide Directive
If the product is sold out
we want to hide it.
var gem = {‹
name: 'Dodecahedron',‹
price: 2.95,‹
description: '. . .',
}.
canPurchase: true,
soldOut: true
>
</div>‹
<script type="text/javascript" src="angular.min.js"></script>‹
<script type="text/javascript" src="app.js"></script>‹
</body> index.html
<button
<body ng-controller="StoreController as store">‹
<div‹
<h1> {{store.product.name}} </h1>‹
<h2> ${{store.product.price}} </h2>‹
<p> {{store.product.description}} </p>
ng-show="store.product.canPurchase"> Add to Cart </button>
NgHide Directive
If the product is sold out
we want to hide it.
This is awkward and
a good example to
use ng-hide!
var gem = {‹
name: 'Dodecahedron',‹
price: 2.95,‹
description: '. . .',
}.
canPurchase: true,
soldOut: true,
ng-show="!store.product.soldOut">
</div>‹
<script type="text/javascript" src="angular.min.js"></script>‹
<script type="text/javascript" src="app.js"></script>‹
</body> index.html
<button
<body ng-controller="StoreController as store">‹
<div‹
<h1> {{store.product.name}} </h1>‹
<h2> ${{store.product.price}} </h2>‹
<p> {{store.product.description}} </p>
ng-show="store.product.canPurchase"> Add to Cart </button>
NgHide Directive
If the product is sold out
we want to hide it.
Much better!
var gem = {‹
name: 'Dodecahedron',‹
price: 2.95,‹
description: '. . .',
}.
canPurchase: true,
soldOut: true,
ng-hide="store.product.soldOut">
Multiple Products
app.js
var gem = ‹
name: "Dodecahedron",‹
price: 2.95,‹
description: ". . .",‹
canPurchase: true,‹
},‹
{
app.controller('StoreController', function(){‹
this.product = gem‹
});‹
;
Multiple Products
app.js
var gems = [‹
‹
name: "Dodecahedron",‹
price: 2.95,‹
description: ". . .",‹
canPurchase: true,‹
},‹
{‹
name: "Pentagonal Gem",‹
price: 5.95,‹
description: ". . .",‹
canPurchase: false,‹
}
‹
];
{
Now we have an array...
How might we display all these
products in our template?
Maybe a
Directive?
app.controller('StoreController', function(){‹
this.products = gems‹
});‹
;
So we have multiple products...
Working with An Array
index.html
<body ng-controller="StoreController as store">‹
<div>‹
<h1> {{store.products[0].name}} </h1>‹
<h2> ${{store.products[0].price}} </h2>‹
<p> {{store.products[0].description}} </p>‹
<button ng-show="store.products[0].canPurchase">‹
Add to Cart</button>‹
</div>‹
. . .‹
</body>
index.html
Working with An Array
. . .‹
</body>
Displaying the first product
is easy enough...
<body ng-controller="StoreController as store">‹
<div>‹
<h1> {{store.products[0].name}} </h1>‹
<h2> ${{store.products[0].price}} </h2>‹
<p> {{store.products[0].description}} </p>‹
<button ng-show="‹
Add to Cart</button>‹
</div>
store.products[0].canPurchase">
Working with An Array
index.html
<body ng-controller="StoreController as store">‹
<div‹
<h1> {{store.products[0].name}} </h1>‹
<h2> ${{store.products[0].price}} </h2>‹
<p> {{store.products[0].description}} </p>‹
<button ng-show="‹
Add to Cart</button>‹
</div>
. . .‹
</body>
<div>‹
<h1> {{store.products[1].name}} </h1>‹
<h2> ${{store.products[1].price}} </h2>‹
<p> {{store.products[1].description}} </p>‹
<button ng-show="store.products[1].canPurchase">‹
Add to Cart</button>‹
</div>
Why repeat yourself?
Why repeat yourself?
Why... You get it.
>
store.products[0].canPurchase">
That works...
Working with An Array
index.html
<body ng-controller="StoreController as store">‹
<div‹
<h1> {{product.name}} </h1>‹
<h2> ${{product.price}} </h2>‹
<p> {{product.description}} </p>‹
<button ng-show="‹
Add to Cart</button>‹
</div>
. . .‹
</body>
ng-repeat="product in store.products"
product
>
Repeat this
section for
each product.
}
.canPurchase">
What We Have Learned So Far
Directives – HTML annotations that trigger Javascript behaviors
Modules – Where our application components live
Controllers – Where we add application behavior
Expressions – How values get displayed within the page
Challenges
243329387 angular-docs

Weitere Àhnliche Inhalte

Was ist angesagt?

Controller in AngularJS
Controller in AngularJSController in AngularJS
Controller in AngularJSBrajesh Yadav
 
AngularJS Project Setup step-by- step guide - RapidValue Solutions
AngularJS Project Setup step-by- step guide - RapidValue SolutionsAngularJS Project Setup step-by- step guide - RapidValue Solutions
AngularJS Project Setup step-by- step guide - RapidValue SolutionsRapidValue
 
AngularJS training - Day 1 - Basics: Why, What and basic features of AngularJS
AngularJS training - Day 1 - Basics: Why, What and basic features of AngularJSAngularJS training - Day 1 - Basics: Why, What and basic features of AngularJS
AngularJS training - Day 1 - Basics: Why, What and basic features of AngularJSmurtazahaveliwala
 
Why angular js Framework
Why angular js Framework Why angular js Framework
Why angular js Framework Sakthi Bro
 
AngularJS best-practices
AngularJS best-practicesAngularJS best-practices
AngularJS best-practicesHenry Tao
 
Orchard Harvest 2014 - The Future of Widgets?
Orchard Harvest 2014 - The Future of Widgets?Orchard Harvest 2014 - The Future of Widgets?
Orchard Harvest 2014 - The Future of Widgets?Steve Taylor
 
Custom directive and scopes
Custom directive and scopesCustom directive and scopes
Custom directive and scopesjagriti srivastava
 
Understanding angular js $rootscope and $scope
Understanding angular js $rootscope and $scopeUnderstanding angular js $rootscope and $scope
Understanding angular js $rootscope and $scopeBrajesh Yadav
 
Getting Started with Angular JS
Getting Started with Angular JSGetting Started with Angular JS
Getting Started with Angular JSAkshay Mathur
 
Angular JS blog tutorial
Angular JS blog tutorialAngular JS blog tutorial
Angular JS blog tutorialClaude Tech
 
AspNetWhitePaper
AspNetWhitePaperAspNetWhitePaper
AspNetWhitePapertutorialsruby
 
AtlasCamp 2015: Using add-ons to build add-ons
AtlasCamp 2015: Using add-ons to build add-onsAtlasCamp 2015: Using add-ons to build add-ons
AtlasCamp 2015: Using add-ons to build add-onsAtlassian
 
AtlasCamp 2015: Web technologies you should be using now
AtlasCamp 2015: Web technologies you should be using nowAtlasCamp 2015: Web technologies you should be using now
AtlasCamp 2015: Web technologies you should be using nowAtlassian
 
AtlasCamp 2015: Connect everywhere - Cloud and Server
AtlasCamp 2015: Connect everywhere - Cloud and ServerAtlasCamp 2015: Connect everywhere - Cloud and Server
AtlasCamp 2015: Connect everywhere - Cloud and ServerAtlassian
 
jQuery and Rails: Best Friends Forever
jQuery and Rails: Best Friends ForeverjQuery and Rails: Best Friends Forever
jQuery and Rails: Best Friends Foreverstephskardal
 
Building and deploying React applications
Building and deploying React applicationsBuilding and deploying React applications
Building and deploying React applicationsAstrails
 

Was ist angesagt? (20)

Angular js
Angular jsAngular js
Angular js
 
Controller in AngularJS
Controller in AngularJSController in AngularJS
Controller in AngularJS
 
AngularJS Project Setup step-by- step guide - RapidValue Solutions
AngularJS Project Setup step-by- step guide - RapidValue SolutionsAngularJS Project Setup step-by- step guide - RapidValue Solutions
AngularJS Project Setup step-by- step guide - RapidValue Solutions
 
AngularJS Best Practices
AngularJS Best PracticesAngularJS Best Practices
AngularJS Best Practices
 
AngularJS training - Day 1 - Basics: Why, What and basic features of AngularJS
AngularJS training - Day 1 - Basics: Why, What and basic features of AngularJSAngularJS training - Day 1 - Basics: Why, What and basic features of AngularJS
AngularJS training - Day 1 - Basics: Why, What and basic features of AngularJS
 
Why angular js Framework
Why angular js Framework Why angular js Framework
Why angular js Framework
 
AngularJS best-practices
AngularJS best-practicesAngularJS best-practices
AngularJS best-practices
 
Orchard Harvest 2014 - The Future of Widgets?
Orchard Harvest 2014 - The Future of Widgets?Orchard Harvest 2014 - The Future of Widgets?
Orchard Harvest 2014 - The Future of Widgets?
 
Custom directive and scopes
Custom directive and scopesCustom directive and scopes
Custom directive and scopes
 
Understanding angular js $rootscope and $scope
Understanding angular js $rootscope and $scopeUnderstanding angular js $rootscope and $scope
Understanding angular js $rootscope and $scope
 
Getting Started with Angular JS
Getting Started with Angular JSGetting Started with Angular JS
Getting Started with Angular JS
 
Angular JS blog tutorial
Angular JS blog tutorialAngular JS blog tutorial
Angular JS blog tutorial
 
AspNetWhitePaper
AspNetWhitePaperAspNetWhitePaper
AspNetWhitePaper
 
EVOLVE'14 | Enhance | Gabriel Walt | Sightly Component Development
EVOLVE'14 | Enhance | Gabriel Walt | Sightly Component DevelopmentEVOLVE'14 | Enhance | Gabriel Walt | Sightly Component Development
EVOLVE'14 | Enhance | Gabriel Walt | Sightly Component Development
 
AngularJS 101
AngularJS 101AngularJS 101
AngularJS 101
 
AtlasCamp 2015: Using add-ons to build add-ons
AtlasCamp 2015: Using add-ons to build add-onsAtlasCamp 2015: Using add-ons to build add-ons
AtlasCamp 2015: Using add-ons to build add-ons
 
AtlasCamp 2015: Web technologies you should be using now
AtlasCamp 2015: Web technologies you should be using nowAtlasCamp 2015: Web technologies you should be using now
AtlasCamp 2015: Web technologies you should be using now
 
AtlasCamp 2015: Connect everywhere - Cloud and Server
AtlasCamp 2015: Connect everywhere - Cloud and ServerAtlasCamp 2015: Connect everywhere - Cloud and Server
AtlasCamp 2015: Connect everywhere - Cloud and Server
 
jQuery and Rails: Best Friends Forever
jQuery and Rails: Best Friends ForeverjQuery and Rails: Best Friends Forever
jQuery and Rails: Best Friends Forever
 
Building and deploying React applications
Building and deploying React applicationsBuilding and deploying React applications
Building and deploying React applications
 

Ähnlich wie 243329387 angular-docs

AngularJs Superheroic JavaScript MVW Framework Services by Miracle Studios
AngularJs Superheroic JavaScript MVW Framework Services by Miracle StudiosAngularJs Superheroic JavaScript MVW Framework Services by Miracle Studios
AngularJs Superheroic JavaScript MVW Framework Services by Miracle StudiosLearnimtactics
 
Angular js
Angular jsAngular js
Angular jsSteve Fort
 
intro to Angular js
intro to Angular jsintro to Angular js
intro to Angular jsBrian Atkins
 
AngularJS Mobile Warsaw 20-10-2014
AngularJS Mobile Warsaw 20-10-2014AngularJS Mobile Warsaw 20-10-2014
AngularJS Mobile Warsaw 20-10-2014Dariusz Kalbarczyk
 
Introduction to angular js july 6th 2014
Introduction to angular js   july 6th 2014Introduction to angular js   july 6th 2014
Introduction to angular js july 6th 2014Simona Clapan
 
AngularJS for Legacy Apps
AngularJS for Legacy AppsAngularJS for Legacy Apps
AngularJS for Legacy AppsPeter Drinnan
 
Introduction of angular js
Introduction of angular jsIntroduction of angular js
Introduction of angular jsTamer Solieman
 
Starting with angular js
Starting with angular js Starting with angular js
Starting with angular js jagriti srivastava
 
AgularJS basics- angular directives and controllers
AgularJS basics- angular directives and controllersAgularJS basics- angular directives and controllers
AgularJS basics- angular directives and controllersjobinThomas54
 
ASP.NET MVC, AngularJS CRUD for Azerbaijan Technical University
ASP.NET MVC, AngularJS CRUD for Azerbaijan Technical UniversityASP.NET MVC, AngularJS CRUD for Azerbaijan Technical University
ASP.NET MVC, AngularJS CRUD for Azerbaijan Technical UniversitySyed Shanu
 
Basics of AngularJS
Basics of AngularJSBasics of AngularJS
Basics of AngularJSFilip Janevski
 
AngularJS in 60ish Minutes
AngularJS in 60ish MinutesAngularJS in 60ish Minutes
AngularJS in 60ish MinutesDan Wahlin
 
Introduction to AngularJS
Introduction to AngularJSIntroduction to AngularJS
Introduction to AngularJSJussi Pohjolainen
 
Angular js
Angular jsAngular js
Angular jsThyda Eng
 
One Weekend With AngularJS
One Weekend With AngularJSOne Weekend With AngularJS
One Weekend With AngularJSYashobanta Bai
 
AngularJS interview questions
AngularJS interview questionsAngularJS interview questions
AngularJS interview questionsUri Lukach
 

Ähnlich wie 243329387 angular-docs (20)

Ng-init
Ng-init Ng-init
Ng-init
 
Ng-init
Ng-init Ng-init
Ng-init
 
AngularJs Superheroic JavaScript MVW Framework Services by Miracle Studios
AngularJs Superheroic JavaScript MVW Framework Services by Miracle StudiosAngularJs Superheroic JavaScript MVW Framework Services by Miracle Studios
AngularJs Superheroic JavaScript MVW Framework Services by Miracle Studios
 
Angular - Beginner
Angular - BeginnerAngular - Beginner
Angular - Beginner
 
Angular js
Angular jsAngular js
Angular js
 
intro to Angular js
intro to Angular jsintro to Angular js
intro to Angular js
 
Let's react - Meetup
Let's react - MeetupLet's react - Meetup
Let's react - Meetup
 
AngularJS Mobile Warsaw 20-10-2014
AngularJS Mobile Warsaw 20-10-2014AngularJS Mobile Warsaw 20-10-2014
AngularJS Mobile Warsaw 20-10-2014
 
Introduction to angular js july 6th 2014
Introduction to angular js   july 6th 2014Introduction to angular js   july 6th 2014
Introduction to angular js july 6th 2014
 
AngularJS for Legacy Apps
AngularJS for Legacy AppsAngularJS for Legacy Apps
AngularJS for Legacy Apps
 
Introduction of angular js
Introduction of angular jsIntroduction of angular js
Introduction of angular js
 
Starting with angular js
Starting with angular js Starting with angular js
Starting with angular js
 
AgularJS basics- angular directives and controllers
AgularJS basics- angular directives and controllersAgularJS basics- angular directives and controllers
AgularJS basics- angular directives and controllers
 
ASP.NET MVC, AngularJS CRUD for Azerbaijan Technical University
ASP.NET MVC, AngularJS CRUD for Azerbaijan Technical UniversityASP.NET MVC, AngularJS CRUD for Azerbaijan Technical University
ASP.NET MVC, AngularJS CRUD for Azerbaijan Technical University
 
Basics of AngularJS
Basics of AngularJSBasics of AngularJS
Basics of AngularJS
 
AngularJS in 60ish Minutes
AngularJS in 60ish MinutesAngularJS in 60ish Minutes
AngularJS in 60ish Minutes
 
Introduction to AngularJS
Introduction to AngularJSIntroduction to AngularJS
Introduction to AngularJS
 
Angular js
Angular jsAngular js
Angular js
 
One Weekend With AngularJS
One Weekend With AngularJSOne Weekend With AngularJS
One Weekend With AngularJS
 
AngularJS interview questions
AngularJS interview questionsAngularJS interview questions
AngularJS interview questions
 

KĂŒrzlich hochgeladen

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Zilliz
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Bhuvaneswari Subramani
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdfSandro Moreira
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Christopher Logan Kennedy
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityWSO2
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...apidays
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vĂĄzquez
 

KĂŒrzlich hochgeladen (20)

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 

243329387 angular-docs

  • 1.
  • 2. Shaping Up with Angular Level 1: Getting Started
  • 3. What you need to know Must know Not so important Nice to know Automated Testing BDD - Behavior Driven Development TDD - Test Driven Development etc HTML & CSS JavaScript jQuery Ruby on Rails Python, PHP, etc Databases
  • 4. Why Angular? If you’re using JavaScript to create a dynamic website, Angular is a good choice. ‱ Angular helps you organize your JavaScript ‱ Angular helps create responsive (as in fast) websites. ‱ Angular plays well with jQuery ‱ Angular is easy to test
  • 5. Traditional Page-Refresh Screencast: Request-Response Application NOTE: Time between user ‹ interaction and response.
  • 6. Web Server HTML JavaScript Response with Webpage & Assets Web Browser URL Request to server Response with Webpage & Assets User clicks on link, new Request HTML JavaScript Browser loads up entire webpage. Browser loads up entire webpage.
  • 7. Screencast: Request-Response Application NOTE: Note how responsive the page is A “responsive” website using Angular
  • 8. Web Server Response with Webpage & Assets Web Browser URL Request to server Response with JSON Data User clicks on link, new Request HTML JavaScript DATA Browser loads up entire webpage. Data is loaded into existing page.
  • 9. Modern API-Driven Application HTML Browser App Data Source Mobile App Developers Server API
  • 10. A client-side JavaScript Framework for adding interactivity to HTML. app.js index.html How do we tell our HTML when to trigger our JavaScript? <!DOCTYPE html>‹ <html>‹ <body‹ . . . </body>‹ </html> function Store‹ alert('Welcome, Gregg!');‹ }‹ (){ > What is Angular JS?
  • 11. <!DOCTYPE html>‹ <html>‹ <body‹ . . . </body>‹ </html> app.js function Store‹ alert('Welcome, Gregg!');‹ }‹ A Directive is a marker on a HTML tag that tells Angular to run or reference some JavaScript code. Directives Name of function to call index.html Controller(){ ng-controller="StoreController">
  • 12. The Flatlanders Store! Screencast: Flatlanders Store Fully Functional
  • 13. Download AngularJS http://angularjs.org/ We’ll need angular.min.js Downloading the libraries Download Twitter Bootstrap http://getbootstrap.com/ We’ll need bootstrap.min.css
  • 14. <!DOCTYPE html>‹ <html>‹ <head>‹ <link rel="stylesheet" type="text/css" href="bootstrap.min.css" />‹ </head>‹ <body>‹ <script type="text/javascript" src="angular.min.js"></script>‹ </body>‹ </html> Getting Started index.html Twitter Bootstrap AngularJS
  • 15. Modules ‱ Where we write pieces of our Angular application. ‱ Makes our code more maintainable, testable, and readable. ‱ Where we define dependencies for our app. Modules can use other Modules...
  • 16. Creating Our First Module Dependencies Other libraries we might need. ‹ We have none... for now
 Application Name AngularJS var app = angular.module('store', [ ]);
  • 17. Including Our Module var app = angular.module('store', [ ]); app.js index.html <!DOCTYPE html>‹ <html>‹ <head>‹ <link rel="stylesheet" type="text/css" href="bootstrap.min.css" />‹ </head>‹ <body>‹ <script type="text/javascript" src="angular.min.js"></script> <script type="text/javascript" src="app.js"></script> </body>‹ </html>
  • 18. Including Our Module var app = angular.module('store', [ ]); app.js <!DOCTYPE html>‹ <html ng-app="store">‹ <head>‹ <link rel="stylesheet" type="text/css" href="bootstrap.min.css" />‹ </head>‹ <body>‹ <script type="text/javascript" src="angular.min.js"></script>‹ <script type="text/javascript" src="app.js"></script>‹ </body>‹ </html> Run this module when the document loads. index.html
  • 19. Allow you to insert dynamic values into your HTML. Expressions Numerical Operations evaluates to String Operations evaluates to + More Operations: http://docs.angularjs.org/guide/expression <p>‹ I am {{4 + 6}}‹ </p> <p>‹ {{"hello" + " you"}}‹ </p> <p>‹ I am 10‹ </p> <p>‹ hello you‹ </p>‹
  • 20. Including Our Module var app = angular.module('store', [ ]); app.js <!DOCTYPE html>‹ <html ng-app="store">‹ <head>‹ <link rel="stylesheet" type="text/css" href="bootstrap.min.css" />‹ </head>‹ <body>‹ <script type="text/javascript" src="angular.min.js"></script>‹ <script type="text/javascript" src="app.js"></script>‹ <p>{{"hello" + " you"}}</p> </body>‹ </html> index.html
  • 22. Working With Data ...just a simple object we want to print to the page. var gem = {‹ name: 'Dodecahedron',‹ price: 2.95,‹ description: '. . .',‹ }.
  • 23. Controllers app.js Notice that controller is attached to (inside) our app. Controllers are where we define our app’s behavior by defining functions and values. Wrapping your Javascript in a closure is a good habit! var gem = {‹ name: 'Dodecahedron',‹ price: 2.95,‹ description: '. . .',‹ }. })(); (function(){‹ var app = angular.module('store', [ ]); app.controller('StoreController', function(){‹ ‹ });
  • 24. Storing Data Inside the Controller app.js Now how do we print out this data inside our webpage? this.product = gem; var gem = {‹ name: 'Dodecahedron',‹ price: 2.95,‹ description: '. . .',‹ }. })(); (function(){‹ var app = angular.module('store', [ ]); app.controller('StoreController', function(){‹ ‹ });
  • 25. <!DOCTYPE html>‹ <html ng-app="store">‹ <head>‹ <link rel="stylesheet" type="text/css" href="bootstrap.min.css" />‹ </head>‹ ! ! ! ! ! ! ! ! </html>‹ <body>‹ <div>‹ <h1> Product Name </h1>‹ <h2> $Product Price </h2>‹ <p> Product Description </p>‹ </div>‹ <script type="text/javascript" src="angular.min.js"></script>‹ <script type="text/javascript" src="app.js"></script>‹ </body> Our Current HTML Let’s load our data into this part of the page. } index.html
  • 26. <body>‹ <div>‹ <h1> Product Name </h1>‹ <h2> $Product Price </h2>‹ <p> Product Description </p>‹ </div>‹ <script type="text/javascript" src="angular.min.js"></script>‹ <script type="text/javascript" src="app.js"></script>‹ </body> (function(){‹ var app = angular.module('store', [ ]);‹ ‹ app.controller('StoreController', function(){‹ this.product = gem; }); . . . })(); app.js index.html Attaching the Controller
  • 27. <body>‹ <div ng-controller="StoreController as store">‹ <h1> Product Name </h1>‹ <h2> $Product Price </h2>‹ <p> Product Description </p>‹ </div>‹ <script type="text/javascript" src="angular.min.js"></script>‹ <script type="text/javascript" src="app.js"></script>‹ </body> Attaching the Controller (function(){‹ var app = angular.module('store', [ ]);‹ ‹ app.controller('StoreController', function(){‹ this.product = gem; }); . . . })(); app.js index.html Controller name Alias Directive
  • 28. <body>‹ <div ng-controller="StoreController as store">‹ ! ! </div>‹ <script type="text/javascript" src="angular.min.js"></script>‹ <script type="text/javascript" src="app.js"></script>‹ </body> index.html Displaying Our First Product (function(){‹ var app = angular.module('store', [ ]);‹ ‹ app.controller('StoreController', function(){‹ this.product = gem; }); . . . })(); app.js <h1> {{store.product.name}} </h1>‹ <h2> ${{store.product.price}} </h2>‹ <p> {{store.product.description}} </p>
  • 29. Understanding Scope Would never print a value! The scope of the Controller is only inside here... } {{store.product.name}} <h1> {{store.product.name}} </h1>‹ <h2> ${{store.product.price}} </h2>‹ <p> {{store.product.description}} </p> <body>‹ <div ng-controller="StoreController as store">‹ ! ! </div>‹ <script type="text/javascript" src="angular.min.js"></script>‹ <script type="text/javascript" src="app.js"></script>‹ </body>
  • 31. </div>‹ <script type="text/javascript" src="angular.min.js"></script>‹ <script type="text/javascript" src="app.js"></script>‹ </body> <body ng-controller="StoreController as store">‹ <div>‹ <h1> {{store.product.name}} </h1>‹ <h2> ${{store.product.price}} </h2>‹ <p> {{store.product.description}} </p> Adding A Button index.html var gem = {‹ name: 'Dodecahedron',‹ price: 2.95,‹ description: '. . .', }.
  • 32. var gem = {‹ name: 'Dodecahedron',‹ price: 2.95,‹ description: '. . .', }. canPurchase: false </div>‹ <script type="text/javascript" src="angular.min.js"></script>‹ <script type="text/javascript" src="app.js"></script>‹ </body> Adding A Button index.html <button How can we only show this button... ...when this is true? Directives to the rescue! <body ng-controller="StoreController as store">‹ <div>‹ <h1> {{store.product.name}} </h1>‹ <h2> ${{store.product.price}} </h2>‹ <p> {{store.product.description}} </p> > Add to Cart </button>
  • 33. var gem = {‹ name: 'Dodecahedron',‹ price: 2.95,‹ description: '. . .', }. canPurchase: false </div>‹ <script type="text/javascript" src="angular.min.js"></script>‹ <script type="text/javascript" src="app.js"></script>‹ </body> NgShow Directive index.html <button <body ng-controller="StoreController as store">‹ <div>‹ <h1> {{store.product.name}} </h1>‹ <h2> ${{store.product.price}} </h2>‹ <p> {{store.product.description}} </p> ng-show="store.product.canPurchase"> Add to Cart </button> Will only show the element if the value of the Expression is true.
  • 34.
  • 35. </div>‹ <script type="text/javascript" src="angular.min.js"></script>‹ <script type="text/javascript" src="app.js"></script>‹ </body> index.html <button <body ng-controller="StoreController as store">‹ <div‹ <h1> {{store.product.name}} </h1>‹ <h2> ${{store.product.price}} </h2>‹ <p> {{store.product.description}} </p> ng-show="store.product.canPurchase"> Add to Cart </button> NgHide Directive If the product is sold out we want to hide it. var gem = {‹ name: 'Dodecahedron',‹ price: 2.95,‹ description: '. . .', }. canPurchase: true, soldOut: true >
  • 36. </div>‹ <script type="text/javascript" src="angular.min.js"></script>‹ <script type="text/javascript" src="app.js"></script>‹ </body> index.html <button <body ng-controller="StoreController as store">‹ <div‹ <h1> {{store.product.name}} </h1>‹ <h2> ${{store.product.price}} </h2>‹ <p> {{store.product.description}} </p> ng-show="store.product.canPurchase"> Add to Cart </button> NgHide Directive If the product is sold out we want to hide it. This is awkward and a good example to use ng-hide! var gem = {‹ name: 'Dodecahedron',‹ price: 2.95,‹ description: '. . .', }. canPurchase: true, soldOut: true, ng-show="!store.product.soldOut">
  • 37. </div>‹ <script type="text/javascript" src="angular.min.js"></script>‹ <script type="text/javascript" src="app.js"></script>‹ </body> index.html <button <body ng-controller="StoreController as store">‹ <div‹ <h1> {{store.product.name}} </h1>‹ <h2> ${{store.product.price}} </h2>‹ <p> {{store.product.description}} </p> ng-show="store.product.canPurchase"> Add to Cart </button> NgHide Directive If the product is sold out we want to hide it. Much better! var gem = {‹ name: 'Dodecahedron',‹ price: 2.95,‹ description: '. . .', }. canPurchase: true, soldOut: true, ng-hide="store.product.soldOut">
  • 38. Multiple Products app.js var gem = ‹ name: "Dodecahedron",‹ price: 2.95,‹ description: ". . .",‹ canPurchase: true,‹ },‹ { app.controller('StoreController', function(){‹ this.product = gem‹ });‹ ;
  • 39. Multiple Products app.js var gems = [‹ ‹ name: "Dodecahedron",‹ price: 2.95,‹ description: ". . .",‹ canPurchase: true,‹ },‹ {‹ name: "Pentagonal Gem",‹ price: 5.95,‹ description: ". . .",‹ canPurchase: false,‹ }
‹ ]; { Now we have an array... How might we display all these products in our template? Maybe a Directive? app.controller('StoreController', function(){‹ this.products = gems‹ });‹ ; So we have multiple products...
  • 40. Working with An Array index.html <body ng-controller="StoreController as store">‹ <div>‹ <h1> {{store.products[0].name}} </h1>‹ <h2> ${{store.products[0].price}} </h2>‹ <p> {{store.products[0].description}} </p>‹ <button ng-show="store.products[0].canPurchase">‹ Add to Cart</button>‹ </div>‹ . . .‹ </body>
  • 41. index.html Working with An Array . . .‹ </body> Displaying the first product is easy enough... <body ng-controller="StoreController as store">‹ <div>‹ <h1> {{store.products[0].name}} </h1>‹ <h2> ${{store.products[0].price}} </h2>‹ <p> {{store.products[0].description}} </p>‹ <button ng-show="‹ Add to Cart</button>‹ </div> store.products[0].canPurchase">
  • 42. Working with An Array index.html <body ng-controller="StoreController as store">‹ <div‹ <h1> {{store.products[0].name}} </h1>‹ <h2> ${{store.products[0].price}} </h2>‹ <p> {{store.products[0].description}} </p>‹ <button ng-show="‹ Add to Cart</button>‹ </div> . . .‹ </body> <div>‹ <h1> {{store.products[1].name}} </h1>‹ <h2> ${{store.products[1].price}} </h2>‹ <p> {{store.products[1].description}} </p>‹ <button ng-show="store.products[1].canPurchase">‹ Add to Cart</button>‹ </div> Why repeat yourself? Why repeat yourself? Why... You get it. > store.products[0].canPurchase"> That works...
  • 43. Working with An Array index.html <body ng-controller="StoreController as store">‹ <div‹ <h1> {{product.name}} </h1>‹ <h2> ${{product.price}} </h2>‹ <p> {{product.description}} </p>‹ <button ng-show="‹ Add to Cart</button>‹ </div> . . .‹ </body> ng-repeat="product in store.products" product > Repeat this section for each product. } .canPurchase">
  • 44. What We Have Learned So Far Directives – HTML annotations that trigger Javascript behaviors Modules – Where our application components live Controllers – Where we add application behavior Expressions – How values get displayed within the page