I have just started learning angular! I have a 'quick view' button on my list of product thumbnail images, the button and images are generated using angular ng-repeat. I need to display the appropriate product description/price etc (from my json file) in a modal when clicking on 'quick view' but can't get anything to show. I was wanting to possibly filter the products using their product code, as this is unique to each item. Any help would be much appreciated.
My html:
<div ng-repeat="product in store.products">
<div class="item col-md-3 col-xs-12">
<div class="product-image-wrapper text-center">
<div class="product">
<div class="image">
<div class="quickview">
<a title="Quick View" class="btn btn-xs btn-quickview" data-target="#product-details-modal" data-toggle="modal" ng-click="selectedProduct = product"> Quick View </a>
</div><!--quickview-->
<a href="#"><product-image></product-image></a>
</div><!--image-->
<p><span class="red"><product-title></product-title></span><br>
</p>
</div><!--product-->
</div><!--product-image-wrapper text-center-->
</div><!--item col-md-3 col-xs-12-->
</div><!--ng repeat-->
× JS
(function() {
var app = angular.module('store-products', []);
app.directive('productGallery', function($scope) {
return {
restrict: 'E',
templateUrl: 'includes/product-gallery.html',
scope: {
product: '=',
},
controller: function() {
this.current = 0;
this.setCurrent = function(imageNumber) {
this.current = imageNumber || 0;
};
},
controllerAs: 'gallerymain'
};
});
app.directive('productImage', function() {
return {
restrict: 'E',
templateUrl: 'includes/product-image.html',
controller: function() {
this.current = 0;
this.setCurrent = function(imageNumber) {
this.current = imageNumber || 0;
};
},
controllerAs: 'gallery'
};
});
app.directive('productTitle', function (){
return {
restrict:'E',
templateUrl: 'includes/product-title.html'
scope: {
product: '=',
},
};
});
app.directive("productDescriptions", function() {
return {
restrict: 'E',
templateUrl: "includes/product-description.html"
scope: {
product: '=',
},
};
});
})();
JSON
[
{
"name": "Up in Flames",
"description": "Covered in dragon scales, this rashguard has a full graphical back showing the flame surrounded dragon itself.",
"price": 24.99,
"code": "FLAME",
"images": [
"images/products/flames/front.jpg",
"images/products/flames/back.jpg",
"images/products/flames/close.jpg"
],
"reviews": []
},
]