Share services, components and pipes in ionic 3.x?

Like the title says what’s the best practice way to create shared services,components and pipes across the app in ionic 3 app. Where everything appears to be modules now.

If I add a service to the share module, do I still add it in provider array in app.module?

1 Like

as I read in their blog, IONIC 3.x will use angular 4

Yes, Indeed and I have the basic app running but wondering to create shared blocks since in ionic 3 one is lazy loading and it’s not bootstrap ing everything in app.module. Reading about this is little confusing

1 Like

Good questions. Angular has supported lazy loading for a while, and this is explained in the official style guide here:!#04-10

However, module loading in Ionic works differently than in Angular, because Ionic doesn’t use the same router. I only just started looking through the v3 code yesterday, but I can tell you that you can set priority of your modules, with any high priority modules loading up front.

Services are the biggest deal, because they are expected to be singletons, and lazy loading (at least in Angular) can cause new copies of services to be created by lazy loaded components. To be honest I’m not sure how this will work in Ionic 3 yet, we’ll have to wait for the official beta at this point to better understand this.