-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
In ngrid 5.0.0 resolving of PblNgridCellFactoryResolver fails in createComponent() #276
Comments
I think I identified the problem. PblNgridCellFactoryResolver should be marked with @Injectable(providedIn: 'root') as this service seems to be use to handle customization of NGRID_CELL_FACTORY. It might be limiting to have single root implementation of resolver but ngridCellFactory function still depends on legacy ComponentFactoryResolver so it needs to be changed anyway which gives an opportunity of handling an argument allowing to vary implementation based on module/grid/injector etc. Unfortunately I am a bit stuck with 5.0.0 as I cannot find a way to re-register PblNgridCellFactoryResolver in root which implementation relying on injector demands. Maybe you have some ideas? |
How about registering the PblNgridCellFactoryResolver directly in the AppModule? Would it solve? @NgModule({
declarations: [
AppComponent
],
imports: [
...
],
providers: [ PblNgridCellFactoryResolver ], // <<<---
bootstrap: [
AppComponent
]
})
export class AppModule {} |
I tried it already and it complains that module ngrid/lib is not exported. |
Would you have a project that reproduces this error to share? As a workaround, maybe you could try passing the injector when creating the component, but I'm not sure it would work. this.viewContainerRef.createComponent(AComponent, {injector: this.injector}); |
Here is a reproducible project: stackblitz.com Clicking on a button will throw an error in a console. |
I was trying to resolve this issue without changing ngrid. |
I found another solution based on this thread Here is the solution Stackblitz |
After switching to Angular 14 and using ngrid 5.0.0 a new error appears which might be related to how ngrid registers it's dependencies.
In a modal service responsible for showing components of a given type, I create components using .viewContainerRef.createComponent() because angular obsoleted ComponentFactoryResolver. If such component contains ngrid, it crashes due to the following error:
Line which triggers the error:
When ngrid is shown in a normally instantiated component, it works fine.
It might be that I might have to do something extra to make PblNgridCellFactoryResolver registration work although I don't know what would help or if there is exposed a default registration function.
The text was updated successfully, but these errors were encountered: