I am creating an application with angular where I have a list of elements (using ng-repeat), and by clicking on each element, I can open the modal to see a more detailed description.
Right now, to switch to another modal, I need to close the previous one, go to the list and click to open another modal. I would like to go directly to the previous / next modal when pressing the previous / next button. I made an example of what I want to achieve.
Here is the html:
<div ng-app="myApp" ng-controller="myCtrl"> <ul> <li ng-repeat="t in turtles"> {{t.name}} - {{t.weapon}} <a ng-click="show = !show">Show more</a> <div class="modal" ng-show="show"> <div class="close" ng-click="show = !show">X</div> {{t.name}} likes to eat {{t.food}} with his {{t.weapon}}! <div class="previous">Previous</div> <div class="next">Next</div> </div> </li> </ul> </div>
And the controller:
var app = angular.module('myApp', []); app.controller('myCtrl', function ($scope) { $scope.turtles = [ { name: "Michellangelo", weapon: "nunchaku", food:"pizza" }, { name: "Donatello", weapon: "bo", food:"pizza" }, { name: "Leonardo", weapon: "katana", food:"turtle soup" }, { name: "Rafael", weapon: "sai", food:"pizza" } ]; $scope.show=false; });
You can see the working Jsfiddle here
angularjs modal-dialog
Joe82
source share