Created
December 12, 2014 19:02
-
-
Save lgdelacruz92/c75fae6a3ef09eadbd78 to your computer and use it in GitHub Desktop.
This file contains hidden or 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="store"> | |
<head> | |
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css"> | |
</head> | |
<body ng-controller="StoreController as store"> | |
<ul class="list-group"> | |
<li class="list-group-item" ng-hide="product.soldOut" ng-repeat="product in store.products"> | |
<h3> | |
{{product.name}} | |
<em class="pull-right">{{product.price}}</em> | |
<img ng-src="{{product.images[0].thumb}}" class="img-responsive"/> | |
</h3> | |
<button ng-show="store.products.canPurchase"> Add to Cart </button> | |
</li> | |
</ul> | |
<script type="text/javascript" src="angular.min.js"></script> | |
<script type="text/javascript" src="app.js"></script> | |
</body> | |
</html> |
This file contains hidden or 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
(function(){ | |
var app = angular.module('store', [ ]); | |
app.controller('StoreController', function(){ | |
this.products = gems; | |
}); | |
var gems = [ | |
{ | |
name: 'Pencil', | |
price: 2.95, | |
description: 'The awesome led pencil', | |
images: [ | |
{ | |
full: 'images/pencil1.jpg', | |
thumb: 'images/pencil1.jpg' | |
}, | |
{ | |
full: 'images/pencil1.jpg', | |
thumb: 'images/pencil2.jpg' | |
}], | |
canPurchase: true, | |
soldOut: false | |
}, | |
{ | |
name: 'Nissan GTR', | |
price: 30.45, | |
description: 'Nissan is a japanese car', | |
canPurchase: true, | |
images: [ | |
{ | |
full: 'images/Nissan1.jpg', | |
thumb: 'images/Nissan1.jpg' | |
}, | |
{ | |
full: 'images/Nissan2.jpg', | |
thumb: 'images/Nissan2.jpg' | |
}], | |
soldOut: false | |
} | |
]; | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment