Check out this demo showcasing the use of angular + ui-bootstrap to trigger a dialog with its own template and controller.
It appears there may be some confusion regarding the relationship between a controller and the DOM. Remember, the controller does not exist within the DOM itself. Instead, the DOM is linked to a $scope that is governed by a controller. In the given example, the controller is loaded when the dialog elements are added to the DOM, but it's important to note that the controller operates independently from the dialog. The dialog could easily utilize the same controller as the main app by simply making a change in the code. The controller and the dialog remain separate entities. Dialogs do not directly execute controllers; they interact with the $scope managed by one.
Update: After some testing, it seems there might be a bug in the example. When dismissing the dialog and attempting to reopen it, only the modal is displayed without the dialog. I am currently investigating this issue to understand what might be causing it.
Update 2: It seems that the problem with reloading the dialog could be related to template caching. In another demo, I added a cache buster to refresh the dialog content, but the modal backdrop fails to reload. The example on the ui-bootstrap page works smoothly with loading and reloading, possibly because they use a hardcoded template instead of a template URL. I encountered challenges replicating this behavior in the demo environment. Working on cutting-edge technology can be quite a challenge.
Update 3: Despite my efforts, I am still struggling to resolve the issue. Seeking guidance, I have posted a question on Stack Overflow for assistance: Opening the same dialog multiple times with $dialog