Skip to content

Instantly share code, notes, and snippets.

@carloscarcamo
Created April 25, 2014 23:31
Show Gist options
  • Save carloscarcamo/11306760 to your computer and use it in GitHub Desktop.
Save carloscarcamo/11306760 to your computer and use it in GitHub Desktop.
<!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>
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