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

时间:2017-02-14 15:37:29

标签: angular angular2-routing

我在组件的构造函数或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)

1 个答案:

答案 0 :(得分:0)

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