Multiple modal from one template Error

hi i got big problem…
i wish multiple modal from 1 template with different images.
problem : same modal opens.
plz help me…

template
-modal.html
-index.html

js
-app.js

img
-0.jpg
-1.jpg
-2.jpg
.
.
.
-n.jpg


–app.js–

  //showImage function is repeated by the loop.
  $scope.showImage = function(index) {  //index = 0  ->  ++1
   $ionicModal.fromTemplateUrl('templates/modal.html', { 
    	scope: $scope,
	animation: 'slide-in-up'
    }).then(function(modal) {
	$scope.modal.[index] =modal; //error
	$scope.modal.[index].show();  //error
	$scope.x=index;
    }); 
  }
  $scope.hideImage = function(){
    $scope.modal.hide();
  }

—modal.html–

<div class="modal divModel transparent">
  <ion-pane class="transparent padding">
    <i class="icon ion-ios-close close-modal" ng-click="hideImage()"></i>
	<img  class="imgModel" ng-src="/img/{{x}}.jpg" class="fullscreen-image"/>
  </ion-pane>