Angular 6+ :ProvidedIn a non root module is causing a circular dependency

前端 未结 4 1537
囚心锁ツ
囚心锁ツ 2021-01-01 08:21

I\'m trying to provide a resolve service via the new providedIn attribute.

This is a translations resolver which I use in a protected module:

<

4条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-01 09:18

    This isn't an Angular dependencies problem.

    The circular reference is generated by the TypeScript compiler when it tries to resolve the circular imports.

    First Solution

    Create a new module named ProtectedResolversModule and use providedIn: ProtectedResolversModule and move the resolvers there.

    Now you can import that module into ProtectedModule and you won't get a circular dependency error when loading ProtectedRoutingModule.

    Second Solution

    Use the providers array of ProtectedModule.

提交回复
热议问题