Angular · Middle · Question 22 of 75

What happens when a component lists a service in its providers?

@Component({ selector: "app-editor", providers: [EditorState] })

Explanation

Component providers create an element injector. Each component instance and its subtree get a separate instance, which is great for per-widget state; it is destroyed with the component.

Further reading

Problem with a question

Angular · Middle · question 22

Test yourself

Take the Angular · Middle quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz