Created
April 25, 2014 23:31
-
-
Save carloscarcamo/11306760 to your computer and use it in GitHub Desktop.
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
<!DOCTYPE html> | |
<html ng-app='ShoppingModule'> | |
<head> | |
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.14/angular.min.js"></script> | |
<meta name="description" content="Dependencies with Modules"/> | |
<meta charset="utf-8"> | |
<title>Dependencies with Modules | |
</title> | |
</head> | |
<body ng-controller="ShoppingController"> | |
<h1>Shop!</h1> | |
<table ng-repeat="item in items"> | |
<tr> | |
<td>{{item.title}}</td> | |
<td>{{item.description}}</td> | |
<td>{{item.price|currency}}</td> | |
</tr> | |
</table> | |
</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
var ShoppingModule = angular.module('ShoppingModule', []); | |
// Set up the service factory to create our Items interface | |
ShoppingModule.factory('Items', function(){ | |
var items = {}; | |
items.query = function(){ | |
return [ | |
{title: 'Paint pots', description: 'Pots full of paint', price: 3.95}, | |
{title: 'Polka dots', description: 'Dots with polka', price: 2.95}, | |
{title: 'Pebbles', description: 'Just little rocks', price: 6.95} | |
]; | |
}; | |
return items; | |
}); | |
ShoppingModule.controller('ShoppingController', ['$scope', 'Items', | |
function($scope, Items){ | |
$scope.items = Items.query(); | |
}]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment