forked from shyamseshadri/angularjs-book
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updates and fixes for version 2 of book
- Loading branch information
1 parent
0ec490c
commit 704afc9
Showing
43 changed files
with
478 additions
and
627 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,29 @@ | ||
<!doctype html> | ||
<html lang='en' ng-app> | ||
<head> | ||
<title>Shopping Cart</title> | ||
</head> | ||
<html ng-app> | ||
<head> | ||
<title>Your Shopping Cart</title> | ||
</head> | ||
<body ng-controller='CartController'> | ||
<h1>Your Shopping Cart</h1> | ||
<div ng-repeat='item in items'> | ||
<span>{{item.title}}</span> | ||
<input ng-model='item.quantity'> | ||
<span>{{item.price | currency}}</span> | ||
<span>{{item.price * item.quantity | currency}}</span> | ||
<button ng-click="remove($index)">Remove</button> | ||
</div> | ||
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.0.4/angular.min.js"></script> | ||
<script> | ||
function CartController($scope) { | ||
$scope.items = [ | ||
{title: 'Paint pots', quantity: 8, price: 3.95}, | ||
{title: 'Polka dots', quantity: 17, price: 12.95}, | ||
{title: 'Pebbles', quantity: 5, price: 6.95} | ||
]; | ||
|
||
<body ng-controller="CartCtrl"> | ||
<h1>Your Shopping Cart</h1> | ||
|
||
<div ng-repeat="item in items"> | ||
<span>{{item.title}}</span> | ||
<input ng-model="item.quantity"> | ||
<span>{{item.price | currency}}</span> | ||
<span>{{item.price * item.quantity | currency}}</span> | ||
<button ng-click="remove($index)">Remove</button> | ||
</div> | ||
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.4/angular.min.js"></script> | ||
<script> | ||
function CartCtrl($scope) { | ||
$scope.items = [ | ||
{title: 'Paint pots', quantity: 8, price: 3.95}, | ||
{title: 'Polka dots', quantity: 17, price: 12.95}, | ||
{title: 'Pebbles', quantity: 5, price: 6.95} | ||
]; | ||
|
||
$scope.remove = function(index) { | ||
$scope.items.splice(index, 1); | ||
} | ||
} | ||
</script> | ||
</body> | ||
</html> | ||
$scope.remove = function(index) { | ||
$scope.items.splice(index, 1); | ||
}; | ||
} | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
<html ng-app=> | ||
<html ng-app> | ||
<body ng-controller="TextController"> | ||
<p>{{someText.message}}</p> | ||
<p>{{someText}}</p> | ||
|
||
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.4/angular.min.js"></script> | ||
<script | ||
src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.4/angular.min.js"> | ||
</script> | ||
|
||
<script> | ||
function TextController($scope) { | ||
var someText = {}; | ||
someText.message = 'You have started your journey.'; | ||
$scope.someText = someText; | ||
$scope.someText = 'You have started your journey.'; | ||
} | ||
</script> | ||
</body> | ||
</html> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,20 @@ | ||
<html ng-app='myApp'> | ||
<body ng-controller="TextController"> | ||
<body ng-controller='TextController'> | ||
<p>{{someText.message}}</p> | ||
|
||
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.4/angular.min.js"></script> | ||
<script | ||
src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.4/angular.min.js"> | ||
</script> | ||
|
||
<script> | ||
var myAppModule = angular.module('myApp', []); | ||
|
||
myAppModule.controller('TextController', | ||
function TextController($scope) { | ||
var someText = {}; | ||
someText.message = 'You have started your journey.'; | ||
$scope.someText = someText; | ||
}); | ||
function($scope) { | ||
var someText = {}; | ||
someText.message = 'You have started your journey.'; | ||
$scope.someText = someText; | ||
}); | ||
</script> | ||
</body> | ||
</html> | ||
</html> |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,53 @@ | ||
// Create a module for our core AMail services | ||
var aMailServices = angular.module('AMail', []); | ||
|
||
// Set up our mappings between URLs, templates, and controllers | ||
function emailRouteConfig($routeProvider) { | ||
$routeProvider. | ||
when('/', { | ||
controller: ListController, | ||
templateUrl: 'list.html' | ||
}). | ||
when('/view/:id', { | ||
controller: DetailController, | ||
templateUrl: 'detail.html' | ||
}). | ||
otherwise({ | ||
redirectTo: '/' | ||
}); | ||
when('/', { | ||
controller: ListController, | ||
templateUrl: 'list.html' | ||
}). | ||
// Notice that for the detail view, we specify a parameterized URL component | ||
// by placing a colon in front of the id | ||
when('/view/:id', { | ||
controller: DetailController, | ||
templateUrl: 'detail.html' | ||
}). | ||
otherwise({ | ||
redirectTo: '/' | ||
}); | ||
} | ||
|
||
// Set up our route so the AMail service can find it | ||
aMailServices.config(emailRouteConfig); | ||
|
||
// Some fake emails | ||
messages = [{ | ||
id: 0, | ||
sender: '[email protected]', | ||
subject: 'Hi there, old friend', | ||
date: 'Dec 7, 2013 12:32:00', | ||
recipients: ['[email protected]'], | ||
message: 'Hey, we should get together for lunch sometime and catch up. There are many things we should collaborate on this year.' | ||
id: 0, sender: '[email protected]', subject: 'Hi there, old friend', | ||
date: 'Dec 7, 2013 12:32:00', recipients: ['[email protected]'], | ||
message: 'Hey, we should get together for lunch sometime and catch up.' | ||
+'There are many things we should collaborate on this year.' | ||
}, { | ||
id: 1, | ||
sender: '[email protected]', | ||
id: 1, sender: '[email protected]', | ||
subject: 'Where did you leave my laptop?', | ||
date: 'Dec 7, 2013 8:15:12', | ||
recipients: ['[email protected]'], | ||
message: 'I thought you were going to put it in my desk drawer. But it does not seem to be there.' | ||
date: 'Dec 7, 2013 8:15:12', recipients: ['[email protected]'], | ||
message: 'I thought you were going to put it in my desk drawer.' | ||
+'But it does not seem to be there.' | ||
}, { | ||
id: 2, | ||
sender: '[email protected]', | ||
subject: 'Lost python', | ||
date: 'Dec 6, 2013 20:35:02', | ||
recipients: ['[email protected]'], | ||
message: "Nobody panic, but my pet python is missing from her cage. She doesn't move too fast, so just call me if you see her." | ||
}, ]; | ||
id: 2, sender: '[email protected]', subject: 'Lost python', | ||
date: 'Dec 6, 2013 20:35:02', recipients: ['[email protected]'], | ||
message: 'Nobody panic, but my pet python is missing from her cage.' | ||
+'She doesn\'t move too fast, so just call me if you see her.' | ||
} ]; | ||
|
||
// Publish our messages for the list template | ||
function ListController($scope) { | ||
$scope.messages = messages; | ||
} | ||
|
||
// Get the message id from the route (parsed from the URL) and use it to | ||
// find the right message object. | ||
function DetailController($scope, $routeParams) { | ||
$scope.message = messages[$routeParams.id]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
<div><strong>Subject:</strong> {{message.subject}}</div> | ||
<div><strong>Sender:</strong> {{message.sender}}</div> | ||
<div><strong>Date:</strong> {{message.date}}</div> | ||
<div><strong>To:</strong><span ng-repeat='recipient in message.recipients'>{{recipient}} </span> | ||
<div> | ||
<strong>To:</strong> | ||
<span ng-repeat='recipient in message.recipients'>{{recipient}} </span> | ||
</div> | ||
<div>{{message.message}}</div> | ||
<a href='#/'>Back to message list</a> | ||
<a href='#/'>Back to message list</a> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,11 @@ | ||
<!doctype html> | ||
<html ng-app="AMail"> | ||
<head> | ||
<!--script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.0.2/angular.min.js"></script--> | ||
<script src='angular.min.js'></script> | ||
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.0.4/angular.min.js"></script> | ||
<script src='controllers.js'></script> | ||
</head> | ||
<body> | ||
<h1>A-Mail</h1> | ||
<div ng-view></div> | ||
</body> | ||
</html> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.