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 badges1 Answer
Reset to default 8You 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');
});
});