$uibModalInstance 是否有像 .ready 或 .opened 这样的属性?我正在尝试根据传递给它的数据更改 UI Bootstrap 模式中元素的 CSS 类。我需要一种在加载模态后触发该功能的方法。我知道 $uibModal 具有 .opened、.close 和 .rendered 等属性,但这会在创建模态的 Controller 中触发,而不是在模态 Controller 本身内触发。由于所有数据都在模态 Controller 内,我无法从外部 Controller 访问它。

有什么建议么?

最佳答案

您可以访问模态 Controller 中的 $uibModalInstance 并执行如下操作:

angular.module('ui.bootstrap.demo').controller('ModalInstanceCtrl', function ($scope, $uibModalInstance, items) {
  $uibModalInstance.rendered.then(function() {
    alert('modal has rendered');
  });

  $uibModalInstance.opened.then(function() {
    alert('modal has opened');
  });

  $uibModalInstance.closed.then(function() {
    alert('modal has closed');
  });
});

关于javascript - $uibModalInstance 是否有像 .ready 或 .opened 这样的属性?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/36487741/

10-12 19:43