Search code examples
angulartypescriptprimengangular2-components

Implementation problem of a PrimeNG Angular2 component with DynamicDialogRef and without DynamicDialogRef


I'm trying to implement a component with dynamic dialog and there is a need to use a direct usage. With the DynamicDialog example, there is a constructor of the car demo list component. constructor(private carService: CarService, public ref: DynamicDialogRef, public config: DynamicDialogConfig) { }

When I use directly <carlist></carlist>, I have an error like this:

ERROR Error: StaticInjectorError(AppModule)[CarslistdemoComponent -> DynamicDialogRef]: StaticInjectorError(Platform: core)[CarslistdemoComponent -> DynamicDialogRef]: NullInjectorError: No provider for DynamicDialogRef! at NullInjector.push.../node_modules/@angular/core/fesm5/core.js.NullInjector.get

Is there anyone can solve this problem or can you give advice to implement a different way?


Solution

  • As I learned, there is no way to implement in same component. I had to implement in seperate components. There is an answer related to this:

    Click to see answer