I am trying to iterate over an array of objects from which I want to display a carousel inside a modal.
I tried using ng-repeat but it's of no rescue.
So, basically what I want to achieve is that on clicking the whats New button a modal should open and the modal then starts a carousel which takes the data from the array of objects.
Here is what I have done so far.
(function() {
'use strict';
var app = angular.module('myApp', []);
app.component("logModal", {
templateUrl: 'logModalTemp.html',
bindings: {
name: '@'
},
controller: function() {
this.title = "Modal using Component";
this.logs = [{
"screenImage": "WhatsNew.png",
"featureName": "User Analysis",
"Desc": "Check it now"
},
{
"screenImage": "Screen.png",
"featureName": "New UI",
"Desc": "UI revamped"
},
{
"screenImage": "Screen.png",
"featureName": "New UI",
"Desc": "UI revamped"
}
];
}
});
})();
<!DOCTYPE html>
<html ng-app="myApp">
<head>
<title>Bootstrap Modal using Component</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.5/angular.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="app.js"></script>
</head>
<body>
<div>
<button type="button" class="btn btn-danger" data-toggle="modal" data-target="#logBTModal">What's New</button>
<!-- Modal Starts -->
<log-modal></log-modal>
<script type="text/ng-template" id="logModalTemp.html">
<div id="logBTModal" class="modal fade" role="dialog">
<div class="modal-dialog">
<!-- Modal content -->
<div class="modal-content">
<!-- Modal header -->
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">{{$ctrl.title}}</h4>
</div>
<!-- Modal body -->
<div class="modal-body">
<!-- Carousel Starts -->
<div id="myCarousel" class="carousel slide" data-ride="carousel">
<div class="carousel-inner" ng-repeat="log in logs">
<div class="item active">
<img ng-src="{{log.screenImage}}">
<div class="content">
<h3>{{log.featureName}}</h3>
<h4>{{log.Desc}}</h4>
</div>
</div>
</div>
<!-- Left and Right controle -->
<a class="left carousel-control" href="#myCarousel" data-slide="prev" style="background: none !important">
<span class="glyphicon glyphicon-chevron-left"></span>
<span class="sr-only">Previous</span>
</a>
<a class="right carousel-control" href="#myCarousel" data-slide="next" style="background: none !important">
<span class="glyphicon glyphicon-chevron-right"></span>
<span class="sr-only">Next</span>
</a>
</div>
</div>
</div>
</div>
</div>
</script>
</div>
</body>
</html>
$ctrl.logslike you did with the modal title.