Ionic or angular shared module



i have trouble to understand shared module face to declarations in app.module.ts, components.module.ts, and mycomponent.module.ts.
On other hand i have trouble to bridge ionic shared module concept use with components.module, face to angular shared module concept use.

A while ago, i thought i had understood this concept but … enabling --prod in build showed me that i don"t understand.

Essentials questions to understand and begin to solve my problem/incomprehension is :

  • do we employ the same concept to use same component in different page and in different component ?
  • what do i need to do to achieve it, in case where i have to reuse several components in differents page and other components ?

Because if i follow shared module concept, i have to declare component in page module that use it and in my-component module that use it too, knowing that page module and my-component module are not related to the same use place.
if i follow this right concept, i am confronted to an error of type ’ type component is part of the declaration of 2 modules […]’.

so what do i need to understand ?

Merry Christmas




I believe that the problem is hard, and I don’t believe there is any good documentation on this right now. The links @robinyo gave are great, and so is the Q&A about modules that is connected to the first link. But some things in those Angular docs are not correct for Ionic, because of how Ionic handles its IonicPageModule.

Just within the last couple weeks, I may have come up with a best practices recommendation for this. Sometime in the new year, I will write it up and circulate it to the Ionic Team, to see how correct or crazy they think I am. And then I’ll either share it here or start over. But my recommendation to you is: just get something working, don’t try to get it super efficient. Unless you want to spend a lot of time just on that problem, instead of on programming your app.


thanks for your response.

to achieve that, in one hand ,i have to test if my code can be built for android and if my app functionnality work.
one other hand, i can"t built with --prod due to “this error”.

Finally, that u adviced me is duplicate some component code and don"t search to factorize, to avoid this error (component is part of […]).

is it right ?


Follow this. if you lazy load.


-> one other hand, i can"t built with --prod due to “this error”.

“1. ionic 2 way: add page component/class(eg AboutPage) to @NgModule’s declarations array and entryComponents array in the app.module.ts file. But when you use --prod to build the project, the about.module.ts file will be auto included, so there will be an error complaining duplicate component declarations. To fix this, you must delete the about.module.ts file.”