Last active
August 29, 2015 14:11
-
-
Save got5/c6142a7670e7d3ec602c to your computer and use it in GitHub Desktop.
Slide 113 TP8
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
(function(){ | |
"use strict"; | |
angular.module('app').directive('productSummary', ['ProductUtils', function (ProductUtils) { | |
return { | |
restrict: 'E', | |
templateUrl: 'templates/partials/productSummary.html', | |
scope:{ | |
product:'=' | |
}, | |
link: function (scope, element, attrs) { | |
scope.getRatingClass = ProductUtils.getRatingCss; | |
}, | |
controller: ['$scope', | |
'UserService', | |
function ($scope,UserService) { | |
$scope.addToCart = function (pItem) { | |
UserService.addToCart(pItem, 1); | |
}; | |
}] | |
} | |
}]); | |
})(); |
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
<article class="k-product hproduct"> | |
<div class="photo-data"> | |
<p> | |
<a href="#"> | |
<img class="photo" ng-src="img/catalog/{{product.id}}.jpg" /> | |
</a> | |
</p> | |
</div> | |
<p class="extra new" ng-if="product.isNew">new</p> | |
<h3 class="fn name"> | |
<a ng-href="#/book/{{product.id}}" title="See Product sheet">{{product.name}}</a> | |
</h3> | |
<p ng-class="getRatingClass(product)"> | |
<span ng-show="product.comments"> | |
<a href="#comments">{{product.comments.length}} comment(s)</a> | |
</span> | |
<span ng-hide="product.comments"> | |
No comment | |
</span> | |
</p> | |
<div class="price-data"> | |
<p class="all-prices"> | |
<strong class="price new">{{product.price | currency}}</strong> | |
</p> | |
</div> | |
<div class="buyZone"> | |
<p class="buy"> | |
<a ng-click="addToCart(product)">Add to basket</a> | |
</p> | |
</div> | |
</article> |
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
<!-- hproduct/ --> | |
<product-summary product="product" ng-repeat="product in products"/> | |
<!-- /hproducts --> |
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
<script src="js/directives/productSummary.js"></script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment