Bird
0
0

Given the command ng generate service user, what files are created by default?

medium📝 component behavior Q13 of 15
Angular - Services and Dependency Injection
Given the command ng generate service user, what files are created by default?
Auser.component.ts and user.component.html
Buser.service.js and user.service.test.js
Cuser.module.ts and user-routing.module.ts
Duser.service.ts and user.service.spec.ts
Step-by-Step Solution
Solution:
  1. Step 1: Understand CLI output for service generation

    The Angular CLI creates a TypeScript service file and a test spec file by default.
  2. Step 2: Identify correct file extensions and names

    Files are named user.service.ts and user.service.spec.ts, matching user.service.ts and user.service.spec.ts.
  3. Final Answer:

    user.service.ts and user.service.spec.ts -> Option D
  4. Quick Check:

    Service + test files = B [OK]
Quick Trick: Service files end with .service.ts and .service.spec.ts [OK]
Common Mistakes:
MISTAKES
  • Confusing service files with component files
  • Expecting .js or .test.js extensions
  • Thinking routing or module files are created

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes