PGoCareerGoCareer prep tools
Home
LoginSign up
  • Java
  • Python
  • AI
  • React
  • Angular
  • PHP
  • Node.js
  • SQL
  • DSA
  • HTML
  • CSS
  • JS
  • Spring
  • ML
  • MongoDB

Angular · Theory

Services & DI

← All stacks

Theory

24/43

Services & DI

Services & DI (and) is simple if you keep it on paper. Asha uses it for MarksService shared by two pages in the campus app.

Services & DI (and) order — meaning → @Injectable + constructor inject → one limit. Dumping ten features helps nobody.

Without Services & DI (and), the campus app gets messy and MarksService shared by two pages is hard to trust.

Services & DI (and) shows up in the campus app. Name MarksService shared by two pages, not “a real-world scenario”.

Services & DI (and) trap — new MarksService() in each component. Asha loses marks for that every viva.

Services & DI (and) is not a lonely heading. Asha ties it to MarksService shared by two pages.

One breath for Services & DI (and), then MarksService shared by two pages, then new MarksService() in each component. Sit down.

Diagram
  MarksPage ──inject──► MarksService
  ReportPage ──inject──► MarksService
  one root instance
Exam tip

For Services & DI (and): definition + the campus app + one failure.

Example

import { Component } from "@angular/core";

@Component({
  selector: "app-root",
  template: `
    <h1>{{ title }}</h1>
    <button (click)="toggle()">Toggle</button>
    <p *ngIf="open">Panel open</p>
  `,
})
export class AppComponent {
  title = "Angular practice";
  open = true;
  toggle() {
    this.open = !this.open;
  }
}

Services & DI: toggle open. Say whether the panel is on screen after one click.

Short notes

  • DefServices & DI (and) — Asha uses it for MarksService shared by two pages in the campus app.
  • RuleServices & DI (and) → @Injectable + constructor inject.
  • RememberServices & DI (and) + the Angular compiler (the campus app).
  • UseServices & DI (and) in the campus app (MarksService shared by two pages).
  • TrapServices & DI (and) — new MarksService() in each component.
  • ExServices & DI (and) → MarksService shared by two pages.

Questions

1

What is Services & DI (and)? Teach it with MarksService shared by two pages.

2

Where does Services & DI (and) show up in the campus app?

3

How do you catch new MarksService() in each component?

4

Change one input on MarksService shared by two pages. Predict the new result.

Previous← RouterNextStandalone Components →
P

GoCareerGo

Utilities · Preparation Hub · Resume · CV · Tools — one workspace.

Workspace

DashboardProfilePreparation HubResume builderCV builderCareer planning

PDF Tools

Merge PDFSplit PDFCompress PDFImage to PDFAll toolsJobs

Image & QR

Compress ImageResize ImageQR ScannerQR GeneratorBlogIT interview prep

Company

FAQFeedbackContactPrivacyTermsSitemap

© 2026 GoCareerGo. Keep moving forward.