javascript - 将相同的信息导入模态

标签 javascript html angularjs cordova ionic-framework

这是我正在尝试制作的广告(电子商店折扣代码)应用程序。

广告列在 Array 中,每个广告有 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,因为同一数组中还有其他项目。

最佳答案

抱歉我的英语不好,我认为你需要的是这样的:

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

在你的 Controller 中:

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

所以在你的 Controller 中你已经有了 item 的值;

关于javascript - 将相同的信息导入模态,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27108958/

相关文章:

javascript - 添加链接后 Bootstrap Button 字体错误

angularjs - 在 angularjs 中渲染 404 而不是重定向 404

javascript - 在悬停时选择 sibling

javascript - 未捕获的 RangeError : Maximum call stack size exceeded. jstree

javascript - 如果我对 'Cannot read property ' *** *' of undefined' 没问题怎么办?

javascript - AngularJs - 在等待新 token 时不会跳过请求

javascript - 为什么我得到 'undefined is not a function' ?

Javascript for 循环条件

javascript - 循环中的多个异步函数调用

javascript - 如何在 Bootstrap Material 设计的输入文本中制作标签支持?