I am using primeng confirmDialog which required the confirmationService in my Angular 10 project but nothing is shown at localhost:4200 and I got the following error in Chrome console.
ERROR NullInjectorError: R3InjectorError(AppModule)[ConfirmationService -> ConfirmationService -> ConfirmationService]:
NullInjectorError: No provider for ConfirmationService!
at NullInjector.get (http://localhost:4200/vendor.js:27059:27)
at R3Injector.get (http://localhost:4200/vendor.js:37225:33)
at R3Injector.get (http://localhost:4200/vendor.js:37225:33)
at R3Injector.get (http://localhost:4200/vendor.js:37225:33)
at NgModuleRef$1.get (http://localhost:4200/vendor.js:50342:33)
at Object.get (http://localhost:4200/vendor.js:48245:35)
at getOrCreateInjectable (http://localhost:4200/vendor.js:30065:39)
at Module.ɵɵdirectiveInject (http://localhost:4200/vendor.js:39896:12)
at NodeInjectorFactory.AppComponent_Factory [as factory] (http://localhost:4200/main.js:158:150)
at getNodeInjectable (http://localhost:4200/vendor.js:30173:44)
Here is my app.component.ts.
import { Component } from '@angular/core';
import { ConfirmationService } from 'primeng/api';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
title = 'angular-tuts';
constructor(private confirmationService: ConfirmationService) { }
confirm() {
this.confirmationService.confirm({
message: 'Are you sure that you want to perform this action?',
accept: () => {
}
});
}
}
Here is the app.component.html
<p-confirmDialog header="Confirmation" icon="pi pi-exclamation-triangle"></p-confirmDialog>
<button type="text" (click)="confirm()" pButton icon="pi pi-check" label="Confirm"></button>
Thanks
module
– Dank