我试图从与模态所在的模块不同的模块中显示一个模态。模态是导航模态,因此我首先加载RootModalComponent
具有路由器的模态,<page-router-outlet></page-router-outlet>
然后onInit
重定向到第一个模态。所有这第一部分都运行良好,但是当我关闭第一个模式时,我收到了这个错误:
CONSOLE ERROR [native code]: ERROR Error: No componentRef found in DetachedRouteHandle
CONSOLE ERROR [native code]: ERROR CONTEXT {
"view": {
"def": {
...
"name": "page-router-outlet",
"attrs": [],
"template": null,
"componentProvider": null,
"componentView": null,
"componentRendererType": null,
"publicP
当我从以下方法调用以下方法时会触发此错误FirstModalComponent
:
onClose(): void {
this.modalParams.closeCallback();
}
最奇怪的是,当我从 关闭模式时SecondModalComponent
,一切都很好!
我遵循了Nativescript
文档:https ://docs.nativescript.org/ui/modal-view-ng来使用模态视图实现导航,除了我的路由器配置完全不同并且RootModalComponent
没有被来自相同的组件调用module
。
标记路由.Module.ts
const routes: Routes = [
{ path: 'first-modal', component: FirstModalComponent },
{ path: 'second-modal', component: SecondModalComponent },
];
@NgModule({
imports: [NativeScriptRouterModule.forChild(routes)],
exports: [NativeScriptRouterModule]
})
export class MarkersModalRoutingModule {}
标记.module.ts
@NgModule({
declarations: [
FirstModalComponent,
SecondModalComponent,
RootModalComponent
],
imports: [
NativeScriptCommonModule,
NativeScriptFormsModule,
MarkersModalRoutingModule
],
schemas: [NO_ERRORS_SCHEMA],
entryComponents: [
RootModalComponent
]
})
export class MarkersModalModule { }
根模态组件.ts
export class RootModalComponent implements OnInit {
constructor(
private router: RouterExtensions,
private activeRoute: ActivatedRoute
) { }
ngOnInit() {
this.router.navigate(['first-modal'], { relativeTo: this.activeRoute });
}
}
根-modal.component.html
<page-router-outlet></page-router-outlet>
有人知道解决方法吗?