(written by @pawel)
We've got a number of bug reports opened for the $dialog
service and while some of them can be fixed by (relatively) simple changes to the existing code-base some other are difficult to solve due to the way current code is structured. Additionally the existing API would benefit from some some simplifications.
This docs aims to list existing issues and propose a new API plus some implementations details that would address existing issues.
As a remainder, docs for the current service are located here: https://github.com/angular-ui/bootstrap/blob/master/src/dialog/README.md
There current API it is not very intuitive as it requires 2 function calls to open a dialog, ex.:
var d = $dialog.dialog({modalFade: false, resolve: {item: function(){ return angular.copy(item); } }});
d.open('dialogs/item-editor.html', 'EditItemController');
This is not only verbose but also confuses people - it is not evident where to pass which arguments (angular-ui/bootstrap#170). Worse yet, this design contributes to watches leak as the open/close semantics is not clear (angular-ui/bootstrap#232). On top of this the chain of 2 methods make mocking for unit tests more difficult that it could be with just one method call.
Then, the current $dialog
service has 2 responsibilities: opening generic dialogs and message boxes. We could split this into 2 separate services (angular-ui/bootstrap#175).
There are number of things that are not well supported in the current implementation:
- opening of several modals / dialogs
- people can't customize backdrops / modal windows as creation of the coresponding DOM elements is hard-coded in the service's JavaScript code (angular-ui/bootstrap#201, angular-ui/bootstrap#295). Moving backrop and modal elements to thier corresponding templates would allow us to move many CSS-related options from JavaScript code to directive templates.
- as of today people don't have any means of providing visual feedback when opening of a modal was triggered but the modal itself is not yet open (for example, promises in the
resolve
section are not yet resolved). Example of such issue: angular-ui/bootstrap#354