繁体   English   中英

在组件构造函数中的异常之后,Angular2 Routing不起作用

[英]Angular2 Routing doesn't work after exception in component constructor

我在构造函数或组件的ngOnInit函数中抛出错误。

它由我的CustomErrorHandler处理,但在它发生之前,它会中断路由。

 Uncaught (in promise): Error: Error in http://localhost:8666/app/modules/orders/orders.component.html:1:46 caused by: Constructor error Error: Error in http://localhost:8666/app/modules/orders/orders.component.html:1:46 caused by: Constructor error at ViewWrappedError.ZoneAwareError (http://localhost:8666/node_modules/zone.js/dist/zone.js:811:33) at ViewWrappedError.BaseError [as constructor] (http://localhost:8666/node_modules/@angular/core/bundles/core.umd.js:1190:20) at ViewWrappedError.WrappedError [as constructor] (http://localhost:8666/node_modules/@angular/core/bundles/core.umd.js:1248:20) at new ViewWrappedError (http://localhost:8666/node_modules/@angular/core/bundles/core.umd.js:6633:20) at CompiledTemplate.proxyViewClass.DebugAppView._rethrowWithContext (http://localhost:8666/node_modules/@angular/core/bundles/core.umd.js:12903:27) at CompiledTemplate.proxyViewClass.DebugAppView.detectChanges (http://localhost:8666/node_modules/@angular/core/bundles/core.umd.js:12876:22) at CompiledTemplate.proxyViewClass.AppView.internalDetectChanges (http://localhost:8666/node_modules/@angular/core/bundles/core.umd.js:12711:22) at CompiledTemplate.proxyViewClass.View_OrdersComponent_Host0.detectChangesInternal (/OrdersModule/OrdersComponent/host.ngfactory.js:29:19) at CompiledTemplate.proxyViewClass.AppView.detectChanges (http://localhost:8666/node_modules/@angular/core/bundles/core.umd.js:12726:18) at CompiledTemplate.proxyViewClass.DebugAppView.detectChanges (http://localhost:8666/node_modules/@angular/core/bundles/core.umd.js:12873:48) at ViewRef_.detectChanges (http://localhost:8666/node_modules/@angular/core/bundles/core.umd.js:9915:24) at RouterOutlet.activate (http://localhost:8666/node_modules/@angular/router/bundles/router.umd.js:5027:46) at ActivateRoutes.placeComponentIntoOutlet (http://localhost:8666/node_modules/@angular/router/bundles/router.umd.js:4302:20) at ActivateRoutes.activateRoutes (http://localhost:8666/node_modules/@angular/router/bundles/router.umd.js:4269:30) at eval (http://localhost:8666/node_modules/@angular/router/bundles/router.umd.js:4205:62) 

我认为这是预期的行为。 在自定义错误处理程序中调用ApplicationRef.tick()应该使路由再次工作。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM