title: Prime-NG Confirm Dialog does not work in a service
body: <p>I just noticed a strange behavior of PrimeNG's Confirm Dialog. In  test.component.html, there is an Input Field. It checks if the typed in value is greater than 150. If it is greater, then a Confirm Button shows up below the Input Field ("Please confirm"). Clicking it shows a Dialog with Yes and No. </p>
  
  <p>The Confirm Button shall vanish after choosing either Yes or No. </p>
  
  <p><strong>Now here's the problem:</strong>
  Vanishing only works if the confirm method is called directly in test.component.ts. I'd like to extract it into a service (customConfirmation.service.ts), but the vanishing does not work there. Do you know why? I have got absolutely no idea. ("this.messagesWeightTest" and the button vanishing do not work.) </p>
  
  <p><strong>test.component.html</strong></p>
  
  <pre><code>&lt;div class="p-col-12 p-md-6 p-lg-5"&gt;
    Weight:
    &lt;div class="ui-inputgroup"&gt;
      &lt;input pInputText type="number" id="weight" name="weight" [(ngModel)]="newTest.testWeight"
             placeholder="---"&gt;
      &lt;span class="ui-inputgroup-addon"&gt;kg&lt;/span&gt;
    &lt;/div&gt;
  
    &lt;div *ngIf="validateIfWeightOutsideRange()"&gt;
      &lt;div&gt;
        &lt;p-confirmDialog key="confirmWeightTest"&gt;&lt;/p-confirmDialog&gt;
        &lt;button type="button" (click)="confirmWeightTest()" pButton icon="pi pi-check"
                label="Please confirm!"&gt;
        &lt;/button&gt;
        &lt;p-messages [value]="messagesWeightTest"&gt;&lt;/p-messages&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  
  &lt;/div&gt;
  </code></pre>
  
  <p>It seems that the whole "accept" and "reject" do not work: </p>
  
  <p><strong>customConfirmation.service.ts</strong></p>
  
  <pre><code>import {Injectable} from '@angular/core';
  import {SessionService} from "./session.service";
  import {ConfirmationService, Message} from "primeng/api";
  
  @Injectable()
  export class CustomConfirmationService {
  
      messagesWeightTest: Message[] = [];
      weightConfirmed: boolean = false;
  
      constructor(private confirmationService: ConfirmationService) {}
  
        confirmWeightTest() {
  
          this.confirmationService.confirm({
            message: 'Are you sure?',
            header: 'Confirmation',
            icon: 'pi pi-exclamation-triangle',
            key: 'confirmWeightTest',
            accept: () =&gt; {
              this.messagesWeightTest = [{
                severity: 'info', summary: 'Confirmed', detail: 'The input is correct.'}];
            this.weightConfirmed = true;
            },
            reject: () =&gt; {
              this.sessionService.newTest.testWeight = null;
          this.weightConfirmed = true;
            }
          });
        }
  }
  </code></pre>
  
  <p>test.component.ts just calls the confirmation method from the service: </p>
  
  <p><strong>test.component.ts</strong></p>
  
  <pre><code>import {Component, Injectable, Input, OnInit} from '@angular/core';
  import {ConfirmationService, Message, SelectItem} from "primeng/api";
  import {trigger, state, style, transition, animate} from '@angular/animations';
  import {FormBuilder, FormControl, FormGroup, Validators} from "@angular/forms";
  import {CustomConfirmationService} from "../services/customConfirmation.service";
  import {ValidationService} from "../services/validation.service";
  
  @Component({
    selector: 'app-test',
    templateUrl: './test.component.html',
    styleUrls: ['./test.component.css']
  })
  
  @Injectable()
  export class TestComponent implements OnInit {
  
   constructor(private fb: FormBuilder,
                private customConfirmationService: CustomConfirmationService,
                private confirmationService: ConfirmationService,
                private validationService: ValidationService) {
  
  }
  
  ngOnInit() {}
  
    // Confirmations for ConfirmDialogs
  
    confirmWeightTest() {
      this.customConfirmationService.confirmWeightTest();
    }
  
    // Validations for ConfirmDialogs --&gt; work!
  
    validateIfWeightOutsideRange() {
      return !!this.validationService.validateIfWeightOutsideRange();
    }
  </code></pre>
  
  <p>Again, if I copy and paste confirmWeightTest() from customConfirmation.service.ts into test.component.ts, everything works fine. I also tested this with another project. </p>
  
  <p>I would be glad if you could tell me whats going on here. </p>
  
  <p>Please also refer to <a href="https://stackoverflow.com/questions/53831431/prime-ng-confirm-dialog-hide-the-button-after-confirmation">Prime-NG Confirm Dialog: Hide the Button after Confirmation</a></p>
  
  <p>I implemented everything as recommended in the answer to this question. Thanks!</p>