I did something similar, I think.
I have a $modal controller that looks like this:
angular.module('myApp').controller('infoCtrl', function ($scope, $uibModalInstance, loading) { $scope.editable = loading; $scope.$watch('editable.status', function(newValue, oldValue) { if (newValue == 'success'){ // close modal $uibModalInstance.close('ok'); } else if (newValue == 'error') { // show error message } }); });
Introduced loading is a service that looks like
myApp.factory('loading', function() { return { status: '' } });
And when I change the status of my boot service to "success" (nowhere, not a modal controller), the modal closes.
I donβt know if this was exactly what you asked for, but I hope this helps too, just ask if something is clear!
EDIT: let's say you have a service with the value isCompleted: false , enter this service in your modal controller and use the $watch function, then when this isCompleted is changed to true , you close the modal.
klskl source share