Javascript 离子模态移除和动画不工作

Javascript 离子模态移除和动画不工作,javascript,jquery,cordova,ionic-framework,Javascript,Jquery,Cordova,Ionic Framework,我使用的是ionic Mode,当我打开ionic Mode并提交按钮时,ionic remove模型无法正常工作,甚至动画也无法正常工作。我尝试使用ionic hide而不是remove,但仍然无法正常工作。有人能告诉我ionic Mode出现了什么问题吗 模态: 'use strict'; (function () { angular.module('main') .service('ModalService', ModalService); ModalSer

我使用的是ionic Mode,当我打开ionic Mode并提交按钮时,ionic remove模型无法正常工作,甚至动画也无法正常工作。我尝试使用ionic hide而不是remove,但仍然无法正常工作。有人能告诉我ionic Mode出现了什么问题吗

模态:

'use strict';
(function () {
      angular.module('main')
     .service('ModalService', ModalService);
     ModalService.$inject = ['$ionicModal', '$log'];
     function ModalService ($ionicModal, $log) {
    var init = function (tpl, $scope) {
      var promise;
      var a = $scope;
      $scope = a;

      promise = $ionicModal.fromTemplateUrl(tpl, {
        scope: $scope,
        animation: 'slide-in-right'
      }).then(function (modal) {
        $scope.modal = modal;
        return modal;
      });

      $scope.openModal = function () {
        $log.log('openModal function got clicked', $scope);
        $scope.modal.show();
      };

      $scope.closeModal = function () {
        $scope.modal.hide();
      };

      $scope.removeModal = function () {
        $scope.modal.remove();
      };

      $scope.$on('$destroy', function () {
        $scope.modal.remove();
      });

      return promise;
    };

    return {
      init: init
    };
  }
})();
要调用离子移除和隐藏的控制器:

function modalFunction (htmlpath) {
  vm.modalListType = 'category';
  ModalService
    .init(htmlpath, $scope)
    .then(function (modal) {
      $log.log('modal success');
      catModal = modal;
      catModal.show();
      vm.search = '';
    });
}

function closeModal () {
  catModal.hide();
}

function removeModal () {
  $log.log('removeModal got called', catModal);
  catModal.remove();
}
Html文件:

<div class="center-align">
      <button class="button trans-but m-t-10" type="submit" ng-click="vm.addProduct()">{{'save_message' | translate}}</button>
    </div>

如果尝试使用函数关闭模态,
$scope.modal.hide()
因为如果使用
remove()
,则必须再次创建模式

一个可能的解决办法是:

function closeModal () {
  $scope.modal.hide();
}


这将位于modalFunction控制器内。

如果尝试使用函数关闭模态,
$scope.modal.hide()
因为如果使用
remove()
,则必须再次创建模式

一个可能的解决办法是:

function closeModal () {
  $scope.modal.hide();
}

这将在你的modalFunction控制器内

function closeModal () {
  $scope.modal.remove();
}