Page 1 of 1

Confirm Dialog ist not opening

Posted: 02 Feb 2018, 11:03
by muelleste
Hi,
i want to get a confirm dialog in my program, but it doesn't work. The Window is not opening, with a normal dialog the use-case worked.

The code above are only snippets from my real .ts file

Code:

Code: Select all

import { MenuItem, TreeNode, ConfirmationService, ConfirmDialogModule } from 'primeng/primeng';

constructor(private route: ActivatedRoute,
              private router: Router,
              private confirmationService: ConfirmationService) 
              
  onDelete() {

    console.log("Confirmservice");
      this.confirmationService.confirm({
          message: 'Test',
          header: 'Confirmation',
          icon: 'fa fa-question-circle',
          accept: () => {
          	console.log("Worked");
              });
          }
        reject: () => {
            console.log("Test");
        }
        }
      )
  }         

my html page:

Code: Select all

                  
                  <div class="ui-g-12 ui-md-4">
                    <button pButton label="Try" icon="ui-icon-delete" (click)="onDelete()"></button>
                  </div>
  
Hope somebody can help me.

Re: Confirm Dialog ist not opening

Posted: 02 Feb 2018, 14:13
by jayee
It looks like you haven't closed your constructor properly with empty { } braces.

I wonder, how come you are not getting any errors when you click on delete button (open dev tools on your browser)?

Re: Confirm Dialog ist not opening

Posted: 09 Feb 2018, 11:42
by merve7
You need to add

Code: Select all

<div class="ui-g-12 ui-md-4">
   <p-confirmDialog></p-confirmDialog>
   <button pButton label="Try" icon="ui-icon-delete" (click)="onDelete()"></button>
</div>
 
And your ts file include extra brackets/semicolon

Code: Select all

onDelete() {
    console.log("Confirmservice");
    this.confirmationService.confirm({
      message: 'Test',
      header: 'Confirmation',
      icon: 'fa fa-question-circle',
      accept: () => {
        console.log("Worked");
      },
      reject: () => {
        console.log("Test");
      }
    })
  }