-
Notifications
You must be signed in to change notification settings - Fork 1
Confirm Dialogue
einarhuseby edited this page May 26, 2019
·
2 revisions
Nlf-client uses the ConfirmService which is based upon ng-bootstrap's NgbModal.
The confirmService is easy to add to existing logic and returns a promise.
import { ConfirmService } from 'app/services/confirm/confirm.service';
constructor(private confirmService: ConfirmService) {}
interface confirmMsg {
title: string;
message: string; // HTML allowed
yes?: string; // defaults 'Yes'
no?: string; // default 'No'
}
Wrap the logic with confirmService and then handle the promise when it returns yes and then no.
public delete(item) {
const confirmMsg = { title: 'Please confirm',
message: 'Are you sure you want to delete ' + item.name + ' ?',
yes: 'Delete',
no: 'Cancel'};
this.confirmService.confirm(confirmMsg).then(
() => { // Yes
this.deleteItem(item);
},
() => { // No
// Do nothing?
}
);
}