Created
May 29, 2014 23:35
-
-
Save aaronroberson/f3b54850ca37634ebd92 to your computer and use it in GitHub Desktop.
Geekwise Day 6 Assets
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(angular) { | |
'use strict'; | |
var app = angular.module('MyStore'); | |
app.directive('msFeaturedProduct', function() { | |
return { | |
restrict: 'E', | |
replace: true, | |
scope: { | |
item: '=product' | |
}, | |
templateUrl: 'templates/featured-product.html', | |
link: function(scope, elem, attrs) { | |
} | |
}; | |
}); | |
})(window.angular); |
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
<div class="featured_small"> | |
<div class="prod_img"> | |
<img ng-src="{{item.thumbnail}}"/> | |
</div> | |
<div class="small_desc"> | |
<h3 ng-bind="item.title"></h3> | |
<p ng-bind="item.description"></p> | |
</div> | |
<div class="action"> | |
<a class="button" ui-sref="product({id: item.guid})"> Read More</a> | |
</div> | |
</div> |
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
<div class="three" ng-repeat="item in featuredProducts | limitTo:4" ng-if="!$first"> | |
<ms-featured-product product="item"></ms-featured-product> | |
</div> |
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="directives/featured-product-directive.js"></script> |
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
// Check if the current product's guid property is equal to id from the URL | |
if(product.guid === product_guid) { | |
// We've found a match, add the matching product to the $scope | |
$scope.product = product; | |
}else if(product.isFeatured) { | |
// Add the featured product to the featuredProducts array | |
$scope.featuredProducts.push(product); | |
} |
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
<div class="row"> | |
<!-- add featured here --> | |
<div class="col-sm-offset-2 col-sm-12 featured"> | |
<div class="small"> | |
<div class="three" ng-repeat="item in featuredProducts | limitTo:3" ng-if="item.guid !== product.guid"> | |
<ms-featured-product product="item"></ms-featured-product> | |
</div> | |
</div> | |
</div> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment