Currently, I'm working on a project that uses angular2-toaster.
// Show message notification
this.toasterService.pop('success',
`New message from ${data.sender.name} (${data.sender.hid})`,
data.message);
When the user clicks to the pop-up, I want to show the dialog for more detail. I've searched the document on https://www.npmjs.com/package/angular2-toaster but can not find the solution to handle the event when user click on the pop-up, can you suggest for me some advice?
Thanks a lot.
You could use the clickHandler
.
@Component({
selector: 'my-app',
template: `
<div>
<toaster-container [toasterconfig]="config1"></toaster-container>
<button (click)="popToast()">pop toast</button><br/>
</div>
`,
})
export class App {
private toasterService: ToasterService;
constructor(toasterService: ToasterService) {
this.toasterService = toasterService;
}
popToast() {
var toast: Toast = {
type: 'info',
title: 'Here is a Toast Title',
body: 'Here is a Toast Body',
showCloseButton: true,
clickHandler: (t, isClosed): boolean => {
console.log('i am clicked..', isClosed, t);
// got clicked and it was NOT the close button!
if (!isClosed) {
}
return true; // remove this toast !
}
};
this.toasterService.pop(toast);
}
}
live-demo: http://plnkr.co/edit/uL98EbfIBd6pm7bMU80V?p=preview