When I try generating providers from Ionic CLI, it generates them in a common providers
directory. But according to Angular 2 docs, the best practices for building a component is to store all the templates, class files and provider files in the component directory itself. So what is a better way and why?
To keep files and code clean, tidy and descriptive in Ionic2 the CLI uses command to generate providers
ionic g provider MyProvider
creates your my-provider
provider inside a directory named providers
inside app
directory. It’s a default directory structure of Ionic2.
For reference, you can follow Ionic2 Conference App
Thank you. Currently, I am using app/providers
directory to store all the shared providers. And page specific providers will be stored along with that page’s directory.
Great… Right… this should be used in many cases… page related providers are kept inside specific page’s directory… as I have seen this in few Github repositories…
Still, you can ask to superior in Ionic 2 if needed.
Happy Coding