triAngular Dialog
AngularJS multi modal dialog module
Installing
To start using triAngular Dialog in your app run:
bower install tri-angular-dialog --save-dev
Then add 'triNgDialog' dependency to modules that will use triDialog (you need to have ngAnimate installed):
angular;
One more thing is decision, which DOM element would be main container for dialogs (body is preferred):
…
Now you can use 'triDialog' service to trigger any dialog:
angular;
Sample dialog config:
Instance
triDialog( … ) returns instance of Dialog (which is also passed to dialog controller or scope):
{
data: any; // data passed as second arg to triDialog()
promise: Promise<any>; // promise resolved on close
close(reason?: any, reject?: boolean): Dialog; // close dialog and resolve promise (or reject)
accept(reason?: any): Dialog; // close dialog and resolve promise with passed reason
cancel(reason?: any): Dialog; // close dialog and reject promise with passed reason
}
Controller
Controller passed to configuration has access to those locals:
{
$dialog: dialog, // instance of dialog, has method 'close()'
$data: dialog.data // shortcut to 'someDataToBePassedToController'
}
If no controller is passed, dialog has attached instance of dialog as '$dialog' to scope;
The Dialog Module can be configured globally
Global values for all dialogs:
app;
You can also pre define dialog configs (and remove those configurations from your controllers/directives/etc:
app;
or config and definitions can be chained:
app;
and use it anywhere:
angular;