Bird
0
0

You want to create a service that is only available to a specific feature module. Which Angular CLI command option helps achieve this?

hard🚀 Application Q8 of 15
Angular - Services and Dependency Injection
You want to create a service that is only available to a specific feature module. Which Angular CLI command option helps achieve this?
Ang generate service feature/data --global
Bng generate service feature/data --module=feature
Cng generate service feature/data --root
Dng generate service feature/data --shared
Step-by-Step Solution
Solution:
  1. Step 1: Understand service scope options

    Using the --module option registers the service in the specified module, limiting its scope.
  2. Step 2: Analyze other options

    --global and --root provide app-wide scope. --shared is not a valid option for service generation.
  3. Final Answer:

    ng generate service feature/data --module=feature -> Option B
  4. Quick Check:

    Use --module to limit service scope to a module [OK]
Quick Trick: Use --module option to scope service to a module [OK]
Common Mistakes:
MISTAKES
  • Using --root for feature-only services
  • Assuming --global limits scope
  • Using invalid options like --shared

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes