-
-
Notifications
You must be signed in to change notification settings - Fork 14
NullInjectorError for ModalDialogParams when opening a modal with ActionBar #82
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
Comments
I just upgraded from Angular 13 to Angular 14 and I'm having the same issue. Where you able to figure it out? JS: ERROR Error: Uncaught (in promise): NullInjectorError: R3InjectorError(ItemsModule)[ModalDialogParams -> ModalDialogParams -> ModalDialogParams -> ModalDialogParams]:
JS: NullInjectorError: No provider for ModalDialogParams!
JS: NullInjectorError: R3InjectorError(ItemsModule)[ModalDialogParams -> ModalDialogParams -> ModalDialogParams -> ModalDialogParams]:
JS: NullInjectorError: No provider for ModalDialogParams! |
Hello @rob4226, |
Hi @alexander-mai So good news, I found a way to get it working. Unfortunately, as we have discovered, injecting constructor(private _modalDialogParams: ModalDialogParams) {} Replace with: /** Need to get modal params from top of stack now that injecting doesn't work. 9/2022 */
private _modalDialogParams: ModalDialogParams;
constructor(private _modalDialogService: ModalDialogService) {}
ngOnInit() {
// Get the most recently opened modal params (from top of stack)
this._modalDialogParams = this._modalDialogService.openedModalParams.slice(-1)[0];
} On a side note, I tried using the new It all almost worked on Android except when I closed the modal, it would also close whatever was behind it in the content pane of the bottom navigation tab. The only way I could get the conent in the bottom navigation to appear again was to navigate to a different bottomtab, then back again. On iOS, it didn't work at all. I kept getting view is undefined error when I tried to open the modal. Luckly the older style modals are still working with the above work around. |
Are you using lazy-loading in your routes for this? I'm having a similar problem related to injector scope in page-router-outlets inside modals, and it looks like it breaks mostly with lazy-loaded modules. |
@JWiseCoder Yes, most of my modules are lazy loaded, and all my modals use a root component with a |
Yes I think that's what's happening in this case: components from routes in lazy-loaded modules are not getting the right injector. |
Environment
Describe the bug
Using modal dialogs is not described in the current documentation for Nativescript 8.x, but in the oder documentation for Nativescript 7.x here: https://v7.docs.nativescript.org/angular/ui/ng-components/modal-view-ng#modal-view-actionbar. When opening a modal with an actionbar the page gets blank and a NullInjectorError for ModalDialogParams is shown in the log:
This happens on android and on ios.
The latest version of Angular 13 and @nativescript/angular 13 is working fine.
To Reproduce
ns debug ios
orns debug android
Expected behavior
SHOW MODAL
should show the modal dialog with an action barSample project
https://github.com/alexander-mai/nativescript-angular14-actionbar-modal-error-example
Additional context
package-angular13.json
contains a working version of thepackage.json
with angular 13 for the projectThe text was updated successfully, but these errors were encountered: