Modular architecture of Ionic 2 application

Hi all,

I would like to know if it’s possible to use the Angular 2 modular architecture (a root App module and feature modules - https://angular.io/docs/ts/latest/guide/ngmodule.html) in Ionic 2 app. The default Ionic 2 app architecture is different (pages, providers and theme directories) and I wonder if it can be changed to a modular application architecture with multiple feature modules, containing components, services, directives and pipes.

It would be great if someone from the Ionic team could write a blog post about it or make a sample application with modular architecture. I am sure it would be very useful for larger mobile applications, as the modular architecture scales much better and is the recommended way to build Angular 2 applications.

1 Like

I bet they are and it’s probably the CHANGELOG of beta.12. Wait a little.

Hello,

So do you have more infos or links that can be provide for this type of modular architecture ? I could’nt find a lot of information about this…

Currently, it’s not really doable.

Thanks for the answer. So what would you suggest for a well structured ionic app ? Do you have some exemples ? :smiley:
Should we just have one root module and all the other pages as components ?

You can use angular style guide structure. It isn’t for ionic but you can use in ionic app too.

https://angular.io/styleguide#!#application-structure-and-angular-modules

1 Like

That’s a rather complicated question at the moment. Generally, I would say “yes”, especially if you have custom components that are included in multiple pages. If, instead, you have a lot of completely independent pages, lazily loading them might be a win for you.

For more context, you can slog through the beta announcement thread, the rxjs bloat thread, lazy loading considered harmful.

Are you sure about that? I think a lot of Angular’s module structure relies on the Angular router, which is not feature compatible with the Ionic navigation system.

2 Likes

True. But you can use shared and core folder structure for ionic. It doesn’t work for lazy routing in ionic but structure easy to understand.

2 Likes