PGoCareerGoCareer prep tools
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 a Angular topic. In plain words you use it for MarksService shared by two pages in the campus app. Don’t start with a slogan — start with that picture.

Smallest example: @Injectable + constructor inject. Type it, run it, and say what you see. If you can do that from memory, you know Services & DI (and).

From the example next to this theory — Services & DI: toggle open.

Trap — new MarksService() in each component. Fix that before you talk about advanced Angular.

Viva — what is Services & DI (and)? Then show @Injectable + constructor inject. Then name the trap.

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

What is Services & DI (and)? Show this: @Injectable + constructor inject. Trap: new MarksService() in each component.

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) — MarksService shared by two pages in the campus app.
  • Rule@Injectable + constructor inject
  • Trapnew MarksService() in each component
  • Usethe campus app

Questions

1

What is Services & DI (and)?

2

Give one small example of Services & DI (and).

3

What mistake do beginners make with Services & DI (and)?

4

Where do you use Services & DI (and)?

24 / 43

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.