I am creating a modal and closing it once data comes in the background.
var modal = modal.open({..some params..});
//after data loads
modal.close();
So my problem is, since everything is asynchronous if my data comes instantaneously then my modal.close() executes before modal opens fully and then my screen remains stuck with the modal screen.
One solution I found is adding a timeout to the modal.close
$timeout(function() {
modal.close();
}, 1)
This works but is it the right way to do it? Or there is some other better solution?