Angular · Senior · Question 20 of 75
What is the difference between providers and viewProviders in a component?
- ✓Correct answer:
viewProvidersare visible to the component's own view but not to content projected into it - 2
viewProvidersare created once per application - 3They are synonyms
Explanation
Use viewProviders to keep an internal service private, so components passed in through <ng-content> by the parent can't accidentally inject it.