Bird
0
0

Given this providers array:

medium📝 Debug Q7 of 15
Angular - Advanced Patterns
Given this providers array:
providers: [
  { provide: 'TOKEN', useValue: 'X', multi: true },
  { provide: 'TOKEN', useValue: 'Y', multi: false }
]

What issue will Angular report?
AError: Mixing multi: true and multi: false for the same token
BNo error; Angular injects ['X', 'Y']
COnly 'X' is injected, 'Y' is ignored
DOnly 'Y' is injected, 'X' is ignored
Step-by-Step Solution
Solution:
  1. Step 1: Understand multi flag consistency

    Angular requires all providers for a token to have the same multi flag value.
  2. Step 2: Analyze given providers

    One provider has multi: true, the other multi: false, causing Angular to throw an error.
  3. Final Answer:

    Error: Mixing multi: true and multi: false for the same token -> Option A
  4. Quick Check:

    Multi flag must be consistent for all providers [OK]
Quick Trick: Keep multi flag consistent for all providers [OK]
Common Mistakes:
  • Mixing multi: true and false for same token
  • Expecting Angular to merge providers anyway
  • Ignoring Angular runtime errors on multi flag mismatch

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes