最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Does $uibModalInstance have any properties like .ready or .opened? - Stack Overflow

programmeradmin4浏览0评论

Does $uibModalInstance have any properties like .ready or .opened? I am trying to change the CSS class of elements within a UI Bootstrap modal based on the data passed to it. I need a way to trigger the function once the modal is loaded. I know $uibModal has properties like .opened, .close, and .rendered, but this triggers in the controller that created the modal, not within the modal controller itself. And since all the data is within the modal controller, I can't access it from the outside controller.

Any suggestions?

Does $uibModalInstance have any properties like .ready or .opened? I am trying to change the CSS class of elements within a UI Bootstrap modal based on the data passed to it. I need a way to trigger the function once the modal is loaded. I know $uibModal has properties like .opened, .close, and .rendered, but this triggers in the controller that created the modal, not within the modal controller itself. And since all the data is within the modal controller, I can't access it from the outside controller.

Any suggestions?

Share Improve this question asked Apr 7, 2016 at 21:41 MichaelMichael 3184 silver badges23 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 8

You can access the $uibModalInstance in the modal controller and do something like so:

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');
  });
});
发布评论

评论列表(0)

  1. 暂无评论