@Tommertom If your app is quite small then yes it is easy to code without following any design patterns, there’s a low chance of getting confused and you don’t need lazy loading.
Services provided in components can still share their state with any child components, that’s why angular best practices state you should provide services from the top-most component from where they will be shared. While it’s true you could provide them in a module, it’s a design practice to keep your code where it’s relevant.
If your service is only used by a component and it’s children, you should only provide it there. Now your code is local to where it’s used. It’s also worth noting that a service provided in a module is a singleton for your entire application unless that module is lazy loaded. That means if you aren’t lazy-loading your module, it doesn’t matter if you provide your service in app.module.ts or page1.module.ts.
In order to prevent app.module from becoming 200 lines of service providing, the best practice guide also recommends putting any services that need to share data across your whole app into a core feature module. You’ll then know that anything in there shares data across your whole app.
Also remember that presently Ionic doesn’t really have proper support for modular code lazy-loading, something I’ve complained about in the past. However, their latest blog post says they are going to start using the Angular router and the Angular CLI. This means for the first time in Ionic you’ll be able to truly make modular code where features are wholly contained in easily reusable and lazy-loadable modules.
So if you were making a user-admin feature for your app you might have a directory structure like this:
This single folder contains a module that provides a user-admin service that talks to your server, a component that represents a single user, and then a main user-admin component that lists out all your users. Not only can all of this code be lazily loaded, the components, the service, even the css (where previously Ionic only supported page component and html lazy-loading), it’s also super easy to reuse this code.
If another app needs user admin, simply copy-paste this folder into your app and import the user-admin.module. That’s it, it will work.
This entire feature is also now self contained, so it’s very clear that the user-admin.service is only used in the user-admin component and it’s child user component, so you can provide it from the user-admin component.