将相同的信息导入模态

时间:2014-11-24 16:01:17

标签: javascript html angularjs cordova ionic-framework

这是我试图制作的广告(电子商店的折扣代码)。

广告列在数组中,每个广告都有4件事(名称,图片链接,折扣(%),折扣代码)

这是我列出广告的方式(使用ng-repeat):

    <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>

因此,当您单击所需的模式时,将打开模态。在模态中,我需要再次显示相同的{{item.name}},然后给它{{item.discountcode}}。我该怎么做?我不能使用ng-repeat,因为同一个数组中还有其他项目。

2 个答案:

答案 0 :(得分:1)

对不起我的英语,我认为你需要的是这样的:

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

在你的控制器中:

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

所以在你的控制器中你已经知道了item的价值;

答案 1 :(得分:0)

将项目作为对象参数传递给modal.show()函数。