Good to answer your questions,
1 - You can create a directive for it that has scope , say type , to which you pass the type of confirmation (i.e. submit to confirm the confirmation, delete to confirm the deletion), and the directive should display a message based on the type you specified.
2 - openConfirm() is a type of ngDialog that can only be closed by confirmation of the action (unlike ngDialog.open() ), so you cannot close the dialog by clicking anywhere in the DOM . confirm() is just the method you use to close the dialog, you use this method to close the dialog and resolve the promise that was returned when the modal file was opened, so it can go <button ng-click="confirm()">Confirm</button> inside your dialog.
Hope this helped you
Update
openConfirm() Opens a dialog box that by default does not close when you hit or click outside the dialog box. The function returns a promise that is either allowed or rejected, depending on how the dialog was closed.
To break a promise, your dialogue should look something like this:
With ngDialog controller
ngDialog.openConfirm({ template: '<div></div>', controller: ['$scope', function($scope) { // Controller logic here }] }).then(function (success) { // Success logic here }, function (error) { // Error logic here });
With directory controller
ngDialog.openConfirm({ template: '<div></div>', scope: $scope, // <- ability to use the scopes from directive controller }).then(function (success) { // Success logic here }, function (error) { // Error logic here });
You can use your directory controller while you go through scope: $scope inside the dialog box
Try switching the type in index.html from confirm to remove and see the updated content and button text in the dialog
Razvan balosin
source share