-
Notifications
You must be signed in to change notification settings - Fork 0
service structure
Raphaël Balet edited this page Dec 6, 2023
·
6 revisions
Where to import which service
This service will be injected only once, could be into the app.module.ts
Example: AppThemeService, SessionService, DarkModeService, ...
@Injectable({
providedIn: 'root',
})
export class sessionService {/** ... **/}src
└── app
└── core
└── services
├── [name].service.ts
├── session.service.ts // example
└── dal.service.ts // exampleMeant to be imported multiple time across the project
Example: loaderService, qrCodeService, ...
@Injectable()
export class loaderService {/** ... **/}src
└── app
└── shared
└── services
└── loader.service.ts // <-- HereThis service will be injected into the component directly
@Injectable()
export class loaderService {/** ... **/}src
└── app
└── pages
└── [page]
├── [page].component.html
├── [page].component.ts
├── [page].module.ts
└── [page].service.ts // [page].module.ts
@NgModule({
declarations: [],
imports: [],
providers: [pageService], // <-- Here
})or
// [page].component.ts
@Component({
standalone: true,
declarations: [],
imports: [],
providers: [pageService], // <-- Here
})