Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to close spModal when switching from one modal to another?

g_eggidio
Kilo Contributor

Hi guys,
I need to close an open spmodal when I switch to a new modal opened by the latter.

What is the best way to do it?

I opened a modal via spmodal.open() in the client-side controller.

Thanks, Giovanni

 

5 REPLIES 5

JonathanJacob
Mega Sage

In case anyone else is facing this issue and doesn't want to use $uibModal. You can inject "$uibModalStack" into your client controller (since spModal wraps it).

Client Script/Controller:

function($scope, spModal, $uibModalStack) {

/* widget controller */
  var c = this;




}

 

Then call when you want to close it... Note: this will close all open modals in the stack.

$uibModalStack.dismissAll();