Angular 2: Bootstrap at least one component before injecting Router

前端 未结 1 1771
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-18 02:27

I get this error in my RC5 app:

Promise rejection: Bootstrap at least one component before injecting Router.

main.ts:

         


        
1条回答
  •  醉梦人生
    2021-01-18 03:09

    Angular thinks it is not necessary to inject Router in the Module level, it is reasonable you inject the Router after at least one component is loaded. I suspect at least one of your services must be injecting Router, which is provided to the loaded Module, which causes this error. What you can do is to inject the service that uses the Router to the app component, so at least one component is loaded first, and all your sub-components will inherit the service from the app component.

    0 讨论(0)
提交回复
热议问题