I was refactoring my project to match the Angular2 styleguide at https://angular.io/guide/styleguide At first I had one module so there was no problem. Now while refactoring and with splitting into modules I got circular dependencies because of the navigation between pages of different modules.
Simplified, I have three modules, each having components:
Shared
- BookListItemComponent
- AjaxSpinnerComponent
- FormHelperComponent
- ...
Books
- BookComponent
Shops
- ShopListComponent
Modules Books
and Shops
each import Shared
. The BookListItemComponent
shows a book title, and when tapped navigates to the BookComponent
which show the book's details.
The ShopListComponent
shows a list of books of a certain shop.
Since the Books
module imports the Shared
module to use the spinner etc. this creates a circular dependency. How are we supposed to solve this?
In an app you navigate between pages of different modules. I don't see a way to avoid having these pointing at each other. Especially with the BookListItemComponent which is used all over the app to list books.
I have also looked at:
- https://forum.ionicframework.com/t/ionic2-navigation-circular-depencies/41123/6
- Circular dependency injection angular 2
But couldn't really map this to my problem.