vapse Adrijus
vapse Adrijus

Reputation: 11

Import same information to modal

It's an ad (discount codes for e-shops) app I'm trying to make.

Ads are listed in to Array , each ad having 4 things (name, image link , discount (%) , discount code)

This is how I list the ads (ng-repeat is used) :

    <div class="list">
    <div class="item item-thumbnail-left" href="#" ng-repeat="item in dovanosListArray" >
      <img ng-src={{item.image}}> 
      <h2>{{item.name}}</h2>
      <button menu-toggle="right"class="button-icon icon ion-ios7-arrow-forward" ng-click="modal.show()"></button>
      <p>Nuolaida : {{item.discount}} %</p> 
    </div>
  </div>

So when you click the one you want, modal opens. In the modal , I need to show the same {{item.name}} again and give it's {{item.discountcode}}. How am i supposed to do this ? I can't use ng-repeat because there are other items in the same array as well.

Upvotes: 1

Views: 43

Answers (2)

Txowi
Txowi

Reputation: 21

Sorry for my English, I think that you need is something like this:

 var modalInstance = $modal.open({
        templateUrl: 'Modal.html',
        controller: 'ModalCtrl',
        resolve: {
        item: function () {
          return item;
          }
        }

And in you controller:

angular.controller('ModalCtrl', ['$scope','item',
                        function($scope,   item , ) {
$scope.item=tem;
 ..........................
}])

So in your controller you already hace the value of item;

Upvotes: 1

Jack Shultz
Jack Shultz

Reputation: 2081

Pass the item as an object parameter in your modal.show() function.

Upvotes: 0

Related Questions