Ionic 4 - Declaring Services and Global Css Classes

#1

Playing around Ionic 4 and I have some very newbie questions.

  1. Declaring Services
    So in Ionic 3 I would declare my providers in app.module.ts, @NgModule -> providers. However I noticed in Ionic 4 this is not required? That is I can just import them directly into the page or component. Is this correct? If two components are using the same service would they still share the same instance of the service?

  2. Global Css Classes
    I would declare css classes in app.scss in Ionic 3. Where would I declare global css classes this now?

Sorry in advance if these are very obvious questions…got to start somewhere

#2

I have the same question

#3

Hello,

  1. Imho providers arte not lazy loaded, so make our entrys in app.module.ts.

  2. Css is imho now more complicated, because styling depends on what you want to style, your components created with ng generate or web components for example created with stencil. For global things is global.scss a useful place.

Best regrads, anna-liebt

#4

Hi All, if you are still working this out it’s actually very easy now esp compared to Ionic 3.

  1. Services, create service using template by typing following command ‘ionic g service myService’ this will automatically create the service temple in the folder you are in. And that’s it, the service is create to root and loaded without any extra code.

  2. Global css, place classed in index.html or global.scss file