NavController, imports and circular dependencies


I am trying to create an injectable class that handles navigation (NavigationService). The class has code like:


and therefore has an import of TabsPage.

On the other hand, the TabsPage component needs to inject the NavigationService.

This seems to create a circular dependency, and always fail with the following error at runtime:

Uncaught Error: Can't resolve all parameters for TabsPage: (?).

Is there a way to escape this circular dependency? Is it possible to use the NavController with strings instead of the actual page type (which causes the problem)?


Generally I think injectables dealing with the view layer is something to be avoided, but I may be in the minority on that. In any event, look into forwardRef.


Thanks @rapropos, it looks like the use of forwardRef solved the problem.