I have say 9 items on a carousel.
I want to show the count of individual items below the the carousel images.
I have created a Plunker for demonstrating the issue.
HTML CODE
<head>
<script data-require="[email protected]" data-semver="1.2.19" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.19/angular.min.js">
</script>
<script data-require="[email protected]" data-semver="2.1.1" src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link rel="stylesheet" href="style.css" />
<link rel="stylesheet" href="http://vasyabigi.github.io/angular-slick/bower_components/slick-carousel/slick/slick.css" />
<script src="http://vasyabigi.github.io/angular-slick/bower_components/slick-carousel/slick/slick.js"></script>
<script src="angular-slick.js"></script>
<script src="script.js"></script>
</head>
<body ng-controller="appController">
<h1>Hello Plunker!</h1>
<button type="button" ng-click="showCount()">Show count of all items</button>
<slick ng-if="dataLoaded" init-onload="false" data="dataLoaded" slides-to-show="3" dots="true">
<div ng-repeat="item in items">
<span>
<img ng-src="{{ item.imgSrc }}" alt="{{ item.catId}}" />
</span>
<span>{{ item.catId }}</span>
</div>
</slick>
JS CODE
var app = angular.module("slick-example", ["slick"]);
app.controller('appController', function($scope, $timeout) {
$scope.items = [];
// simulate that the data is loaded from a remote source
$timeout(function() {
$scope.items = [{
imgSrc: 'http://placekitten.com/325/325',
catId: '1'
}, {
imgSrc: 'http://placekitten.com/g/325/325',
catId: '2'
}, {
imgSrc: 'http://placekitten.com/325/325',
catId: '3'
}, {
imgSrc: 'http://placekitten.com/g/325/325',
catId: '4'
}, {
imgSrc: 'http://placekitten.com/325/325',
catId: '5'
}, {
imgSrc: 'http://placekitten.com/g/325/325',
catId: '6'
}, {
imgSrc: 'http://placekitten.com/325/325',
catId: '7'
}, {
imgSrc: 'http://placekitten.com/g/325/325',
catId: '8'
}, {
imgSrc: 'http://placekitten.com/325/325',
catId: '9'
}];
$scope.countItem = [{
"catId": 1,
"availableCount": 2
}, {
"catId": 2,
"availableCount": 3
}, {
"catId": 3,
"availableCount": 4
}, {
"catId": 4,
"availableCount": 2
}, {
"catId": 5,
"availableCount": 1
}, {
"catId": 6,
"availableCount": 5
}, {
"catId": 7,
"availableCount": 3
}, {
"catId": 8,
"availableCount": 2
}, {
"catId": 9,
"availableCount": 1
}];
// update the dataLoaded flag after the data has been loaded
// i dont know why but its important that the flag doesnt get initialized in an previous step like $scope.dataLoaded = false;
$scope.dataLoaded = true;
}, 2000);
$scope.showCount = function() {}
});
When the button (button - Show count of individual items) is clicked I am trying to show the count of individual items below each image in carousel but I am not able to find a way to do so. On the click of the button count of all items is to be shown
Please refer the Plunker ( I am only using AngularJS and vanilla JS ,no Jquery )
Please help me how to show the count of individual items of the carousel just below each image