Here's a plnkr demonstrating the use of angular + ui-bootstrap to launch a dialog with its own template and controller.
It sounds like you are a bit confused by the relationship between the controller and the DOM. The controller does not live inside the DOM, in fact we are trying to keep two things separate. Rather, the DOM is associated with $ scope, which is controlled by the controller ... (you guessed it ...).
So, in the example, the controller is loaded when the dialog elements are added to the DOM, but the controller does not "open in the dialog" in any meaningful way. In the dialog box, you can just as easily use the same controller as the main application, replacing "DialogCtl" with "DemoCtl" on line 17 of the demo. I am trying to say that the controller and the dialog are independent. Dialogs do not execute controllers, rather, they consume $scope , managed by one.
UPDATE: I just found out that the example is a bit wrong if you reject the dialog and then try to reopen it, the modal will be displayed, but not the dialog. I'm trying to figure it out now, I'm not quite sure what is happening ...
UPDATE 2: I think the impossibility of reloading the dialog is related to template caching. In this plnkr, you see that I am adding "cache bitter" to the request queue, and the dialog is reloaded, but the modal background does not work. The example on the ui-bootstrap page can be loaded and reloaded without problems, but they use a hard-coded pattern (not a URL pattern). I also could not get this job in plnkr. Oh, the joys of working on the brink of bleeding: - /
UPDATE 3: I canβt understand what is happening, but posted this question for reference Several times opening the same dialog with the $ dialog
source share