Angular dialog module
4 people use it
Author: 5089377?v=3 doodeec





This is a dialog module for angular. It creates and makes DialogService service available in your app.

DialogService allows you to create dialog in this way:

where optional config object is used to configure the dialog. For example you can call

and call different methods:

or register a custom callStack of functions for these events:

  • open
  • ready (called once template for modal is resolved - resolving template starts directly inside modal constructor)
  • dismiss
  • destroy (when modal is being destroyed, it gets dismissed first, so dismissed stack is called before destroy stack)

like this

Closing the modal with ESC key, or with Backdrop click are both supported. Closing with Backdrop click can be disabled by setting backdrop option to false when creating a new modal.

When dialog is created without template config parameter, default template will be used to create a dialog. Default template looks like this:

So you can create simple dialogs without any need to create your custom templates. DialogService provides a method setDefaultTemplate(string) which you can use to customize default template and use simple dialogs without template config parameter.

Service also provides a way to define base path for templates (default value is empty - all paths are taken as relative/absolute). When you have all your dialog templates in i.e. templates/dialogs folder, you can easily set this path via setBaseTemplatePath("templates/dialogs"). Calling

afterwards will result in using dialog template templates/dialogs/404.html


Include dcModal-{version}.js and dcModal-{version}.css files in your website and in the app module definition add dcModal as a required module


Service methods


Supported Config Options


Thanks to capaj for the initial idea.


Released under MIT licence.


Tested across Angular 1.0.6 - 1.2.14 - 1.3.15, but probably should be also compatible with other versions.

If you encounter any problems using this module, contact me via or send me an email


If you want to make this code better, feel free to open a PR


Dusan Bartos

comments powered by Disqus
This page was last updated over 3 years ago.