Confirm Dialog ist not opening

Post Reply
muelleste
Posts: 2
Joined: 30 Jan 2018, 15:59

02 Feb 2018, 11:03

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.

jayee
Posts: 5
Joined: 26 Nov 2017, 12:22

02 Feb 2018, 14:13

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)?

merve7
Posts: 201
Joined: 12 Sep 2017, 10:44

09 Feb 2018, 11:42

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");
      }
    })
  }

Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 1 guest