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?
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');
});
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With