javascript - 将数据传递给服务创建的 Ionic 模式

标签 javascript ionic-framework

我正在使用以下solution创建一个 Ionic Modal 服务,但目前,我发现很难将 a 传递到我的模态中。我可以做什么来纠正这个问题:

controller.js

$scope.confirmBookingModal = function(val) {
  console.log(val);
  ModalService.show('templates/modals/confirm-booking.html', 'ConsumerBusinessProfileCtrl as vm', val);
}

模态

<ion-modal-view ng-controller="ConsumerBusinessProfileCtrl">

  <ion-header-bar>
    <h1 class="title">Confirm</h1>
    <div class="buttons">
      <button class="button button-clear" ng-click="closeModal()">Close</button>
    </div>
  </ion-header-bar>

  <ion-header-bar class="bar bar-subheader bar-dark modal-padding">
    <h1 class="title">{{ vm.val }} services booked at £110 for 2 hours</h1>
  </ion-header-bar>


  <ion-content>
  </ion-content>

</ion-modal-view>

val 将一个值输出到控制台,因此其中有一些数据,但我不确定是否从模式中以正确的方式访问它。

最佳答案

由于您已经在 .show() 方法调用中指定了 Controller ,因此在模态模板中不需要它。将模态模板更改为:

<ion-modal-view>

  <ion-header-bar>
    <h1 class="title">Confirm</h1>
    <div class="buttons">
      <button class="button button-clear" ng-click="closeModal()">Close</button>
    </div>
  </ion-header-bar>

  <ion-header-bar class="bar bar-subheader bar-dark modal-padding">
    <h1 class="title">{{ vm.val }} services booked at £110 for 2 hours</h1>
  </ion-header-bar>


   <ion-content>
   </ion-content>

</ion-modal-view>

关于javascript - 将数据传递给服务创建的 Ionic 模式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37217907/

相关文章:

javascript - 访问 .html 内的元素

javascript - 无法加载 angularjs 库

javascript - ionic 的路由问题

javascript - 如何在表格的列中添加省略号

reactjs - 如何停止react-qr-reader(的相机)

javascript - 返回在循环中调用的回调结果的串联

javascript - 删除变量的值而不丢失其子方法

java - 如何使用 javascript 或 java 使用打印命令打印 JSP 页面中包含的表格?

javascript - 使用 ngStorage 将数据绑定(bind)到 localStorage - 这里出了什么问题?

angular - IONIC - VirtualScroll 性能问题