1

我正在尝试在 Angular 2 的最终版本中实现身份验证服务,我只有两个组件:登录组件和管理组件,我是管理组件,但导致以下错误,因为我没有选择要早于管理员加载的组件, 这个问题有什么锻炼方法吗?

zone.js:344 Unhandled Promise rejection: Bootstrap at least one component before injecting Router. ; Zone: <root> ; Task: Promise.then ; Value: Error: Bootstrap at least one component before injecting Router.(…) Error: Bootstrap at least one component before injecting Router.
at setupRouter (http://localhost:3000/scripts/@angular/router//bundles/router.umd.min.js:13:18707)
at NgModuleInjector.get (AppModule.ngfactory.js:372:57)
at NgModuleInjector.AppModuleInjector.createInternal (AppModule.ngfactory.js:561:64)
at NgModuleInjector.create (http://localhost:3000/scripts/@angular/core//bundles/core.umd.min.js:30:1140)
at NgModuleFactory.create (http://localhost:3000/scripts/@angular/core//bundles/core.umd.min.js:30:673)
at eval (http://localhost:3000/scripts/@angular/core//bundles/core.umd.min.js:29:25106)
at ZoneDelegate.invoke (http://localhost:3000/scripts/zone.js/dist/zone.js:192:28)
at Object.onInvoke (http://localhost:3000/scripts/@angular/core//bundles/core.umd.min.js:29:16609)
at ZoneDelegate.invoke (http://localhost:3000/scripts/zone.js/dist/zone.js:191:34)
at Zone.run (http://localhost:3000/scripts/zone.js/dist/zone.js:85:43)consoleError @ zone.js:344_loop_1 @ zone.js:371drainMicroTaskQueue @ zone.js:375ZoneTask.invoke @ zone.js:297

zone.js:346 错误:未捕获(承诺中):错误:在注入路由器之前引导至少一个组件。(...)

4

1 回答 1

4

通过删除 AuthService 上的 ngOnInit() 方法解决了这个问题

于 2016-09-27T16:00:34.293 回答