You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Dec 4, 2017. It is now read-only.
Technically we could, but our component wouldn’t quite behave the way it is supposed to. Remember that each injector treats the services that it provides as singletons. However, in order to be able to have multiple instances of `HeroEditComponent` edit multiple heroes at the same time we need to have multiple instances of the `RestoreService`. More specifically, each instance of `HeroEditComponent` needs to be bound to its own instance of the `RestoreService`.
150
153
@@ -159,20 +162,14 @@ figure.image-display
159
162
we would have exactly one instance of that service and it would be shared across the entire application.
160
163
161
164
That’s clearly not what we want in this scenario. We want each component to have its own instance of the `RestoreService`.
162
-
Defining (or re-defining) a provider at the component level creates a new instance of the service for each new instance
165
+
Defining (or redefining) a provider at the component level creates a new instance of the service for each new instance
163
166
of that component. We've made the `RestoreService` a kind of "private" singleton for each `HeroEditComponent`,
164
167
scoped to that component instance and its child components.
165
168
166
-
<!--
167
-
## Advanced Dependency Injection in Angular 2
168
-
169
-
Restrict Dependency Lookups
170
-
[TODO] (@Host) This has been postponed for now until we come up with a decent use case
171
-
172
-
173
-
.l-main-section
174
-
:marked
175
-
## Dependency Visibility
176
-
177
-
[TODO] (providers vs viewProviders) This has been postponed for now until come up with a decent use case
178
-
-->
169
+
//- ## Advanced Dependency Injection in Angular 2
170
+
//- Restrict Dependency Lookups
171
+
//- [TODO] (@Host) This has been postponed for now until we come up with a decent use case
172
+
//- .l-main-section
173
+
//- :marked
174
+
//- ## Dependency Visibility
175
+
//- [TODO] (providers vs viewProviders) This has been postponed for now until come up with a decent use case
Technically we could, but our component wouldn’t quite behave the way it is supposed to. Remember that each injector treats the services that it provides as singletons. However, in order to be able to have multiple instances of `HeroEditComponent` edit multiple heroes at the same time we need to have multiple instances of the `RestoreService`. More specifically, each instance of `HeroEditComponent` needs to be bound to its own instance of the `RestoreService`.
150
153
@@ -159,20 +162,14 @@ figure.image-display
159
162
we would have exactly one instance of that service and it would be shared across the entire application.
160
163
161
164
That’s clearly not what we want in this scenario. We want each component to have its own instance of the `RestoreService`.
162
-
Defining (or re-defining) a provider at the component level creates a new instance of the service for each new instance
165
+
Defining (or redefining) a provider at the component level creates a new instance of the service for each new instance
163
166
of that component. We've made the `RestoreService` a kind of "private" singleton for each `HeroEditComponent`,
164
167
scoped to that component instance and its child components.
165
168
166
-
<!--
167
-
## Advanced Dependency Injection in Angular 2
168
-
169
-
Restrict Dependency Lookups
170
-
[TODO] (@Host) This has been postponed for now until we come up with a decent use case
171
-
172
-
173
-
.l-main-section
174
-
:marked
175
-
## Dependency Visibility
176
-
177
-
[TODO] (providers vs viewProviders) This has been postponed for now until come up with a decent use case
178
-
-->
169
+
//- ## Advanced Dependency Injection in Angular 2
170
+
//- Restrict Dependency Lookups
171
+
//- [TODO] (@Host) This has been postponed for now until we come up with a decent use case
172
+
//- .l-main-section
173
+
//- :marked
174
+
//- ## Dependency Visibility
175
+
//- [TODO] (providers vs viewProviders) This has been postponed for now until come up with a decent use case
0 commit comments