DialogService is a singleton that provides few ways for you to show/hide dialogs. Here, we predefined alert/confirm/prompt dialogs to replace window.alert/window.confirm/window.prompt if you want any further controls of animations and UI.
And also, there is one more dialog called panelDialog that would be used when you are going to show any predefined panel in dialog way.
API:
- Alert dialog
DialogService.alert({ id: 'MessageId', args: {} }, { title: { id: 'TitleId', args: {} } }) .then(function(result) { var type = result.type; });
NOTE: If there is no args in locales, you can direclty pass l10nId without args.
DialogService.alert('MessageId', { title: 'TitleId' }) .then(function(result) { var type = result.type; });
- Confirm dialog
DialogService.confirm({ id: 'MessageId', args: {} }, { title: { id: 'TitleId', args: {} }, submitButton: { id: 'SubmitButtonId', args: {}, style: 'recommend' }, cancelButton: { id: 'CancelButtonId', args: {} } }) .then(function(result) { var type = result.type; });
- Prompt dialog
DialogService.prompt({ id: 'MessageId', args: {} }, { title: { id: 'TitleId', args: {} }, defaultValue: 'e.g. [email protected]', }).then(function(result) { var type = result.type; var value = result.value; });
- Panel dialog
DialogService.show('screen-lcok', { transition: 'zoom-in', }).then(function(result) { // type would be submit or cancel var type = result.type; var value = result.value; });
NOTES: We support some customized options for each dialog, please check the API below to know what you can customize !
- Source: