Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does $uibModalInstance have any properties like .ready or .opened?

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?

like image 905
Michael Avatar asked Mar 12 '23 16:03

Michael


1 Answers

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');
  });
});
like image 51
Rob J Avatar answered Apr 09 '23 21:04

Rob J