如何在离子 1 中将日期从控制器传递到模态



我想将数据从控制器传递到离子模态,但我没有找到任何方法来做到这一点。 所以请提出一些建议

what i have tried:-
var modalInstance = $modal.open({
  templateUrl: 'confirm_booking.html',
  controller: 'confirm_bookCtl',
  resolve: {
    items: function () {
      return $scope.items;
    }
  }
});
but $modal is undefined in controller

//首先,您不需要声明控制器,因为您可以从控制器调用模态

.controller('MyController', function($scope, $ionicModal) {
   $ionicModal.fromTemplateUrl('templates/modal-template.html', {
      scope: $scope,
      animation: 'slide-in-up',
   }).then(function(modal) {
      $scope.modal = modal;
   });
   $scope.openModal = function() {
      $scope.modal.show();
   };
   $scope.closeModal = function() {
      $scope.modal.hide();
   };
   //Cleanup the modal when we're done with it!
   $scope.$on('$destroy', function() {
      $scope.modal.remove();
   });
   // Execute action on hide modal
   $scope.$on('modal.hidden', function() {
      // Execute action
   });
   // Execute action on remove modal
   $scope.$on('modal.removed', function() {
      // Execute action
   });
});

也许你最好访问这个页面

https://www.tutorialspoint.com/ionic/ionic_js_modal.htm

最新更新