Shows simple text dialogs with just a method call, and reduces boilerplate for more complex dialogs.
A simple text dialog:
const choice = await slDialogService.open({ text: 'Discard draft?', buttons: [{ text: 'Cancel' }, { text: 'Discard' }]});if (choice === 'Discard') { // discard the draft} Copy
const choice = await slDialogService.open({ text: 'Discard draft?', buttons: [{ text: 'Cancel' }, { text: 'Discard' }]});if (choice === 'Discard') { // discard the draft}
Using a custom component:
@Component({ template: ` <h3>Heading 1</h3> <p>Paragraph 1</p> <h3>Heading 2</h3> <p>Paragraph 2</p> `})class FancyDialogComponent {}slDialogService.open({ title: 'My title', component: FancyDialogComponent,}); Copy
@Component({ template: ` <h3>Heading 1</h3> <p>Paragraph 1</p> <h3>Heading 2</h3> <p>Paragraph 2</p> `})class FancyDialogComponent {}slDialogService.open({ title: 'My title', component: FancyDialogComponent,});
Resolves when the dialog is closed. Resolves to the DialogButton.value of the clicked button, or to undefined if the dialog was closed another way (such as clicking off it).
undefined
Shows simple text dialogs with just a method call, and reduces boilerplate for more complex dialogs.
A simple text dialog:
Using a custom component: