I know it might be a simple question, but I'm frustrated here, and I can't make it work. I'm new to AngularJS, and I'm trying to implement a modal dialog (or find one) with these conditions:
- Dialog content might come from anywhere—a string template, a script template, or a template from a URL
- Dialog title and actions will come from the caller, not the callee. In other words, the parent scope decides the title and which action buttons should exist in the modal dialog (many dialogs I found encapsulate the title and action buttons in the template itself, for example this one)
- Content of the template should be totally independent from parent scope (caller). In fact, it might not even be written in AngularJS. It might use jQuery.
In case the loaded template is in AngularJS, it should encapsulate its controller. For example,
ng-include
doesn't like<script>
tags.There is a workaround for it (here, here and here) but the idea of decorating a script tag with
text/javascript-lazy
is very smelly and dirty, let alone that I want the content HTML to be self-contained and executable in case it's not loaded as the content of an AngularJS modal dialog.Communication between the parent scope and the content should be done via a common contract (JavaScript events come to my mind)
I've tried ngDialog
, but the problem is that the container should pass the controller
to the loaded template. That's not what I want.
In Bootstrap dialog also it seems that you have to pass the controller
from the parent scope to the dialog content. This breaks the very notion of encapsulation. It's not desirable. Also, it's dependent on dialog result, which is not desirable either.