Skip to content

Instantly share code, notes, and snippets.

@keithstric
Last active July 21, 2021 17:02
Show Gist options
  • Save keithstric/f23d147b75eeda7bfb5080b2d13f714e to your computer and use it in GitHub Desktop.
Save keithstric/f23d147b75eeda7bfb5080b2d13f714e to your computer and use it in GitHub Desktop.
// Show a very simple dialog
const textModalConfig = {
modalTitle: 'A reusable modal dialog',
modalTextContent: 'Here is the body of the dialog',
data: {foo: 'bar'},
confirmButtonLabel: 'Roger that!',
confirmHandler: (data) => {
console.log('Modal confirm handler', data);
},
cancelHandler: () => {
console.log('Modal cancel handler');
}
};
const modalRef = NotificationService.showConfirmDialog(textModalConfig);
// Show a template as the body
const txt = 'Some TEXT'
const cancelHandler = () => {
console.log('Modal cancel handler');
};
@ViewChild('someTemplate') someTemplate: TemplateRef<any>;
const templateModalConfig = {
modalTitleHtml: `<div>${txt}</div>`,
modalTemplateContent: someTemplate,
data: {foo: 'bar'},
confirmButtonLabel: 'Roger that!',
confirmHandler: (data) => {
console.log('Modal confirm handler', data);
},
cancelHandler: cancelHandler.bind(this)
};
const modalRef = NotificationService.showConfirmDialog(templateModalConfig);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment