把“作用范围”批量改为“作用域”

This commit is contained in:
Zhicheng Wang 2016-07-24 17:31:51 +08:00
parent 4400deeef8
commit 28fe7d848f
5 changed files with 7 additions and 7 deletions

View File

@ -397,7 +397,7 @@ a(id="countdown-tests")
The scope of the service instance is the parent component and its children. Components outside this component subtree have no access to the service or their communications. The scope of the service instance is the parent component and its children. Components outside this component subtree have no access to the service or their communications.
该服务实例的作用范围被限制在父组件和其子组件内。这个组件子树之外的组件将无法访问该服务或者与它们通讯。 该服务实例的作用被限制在父组件和其子组件内。这个组件子树之外的组件将无法访问该服务或者与它们通讯。
This `MissionService` connects the `MissionControlComponent` to multiple `AstronautComponent` children. This `MissionService` connects the `MissionControlComponent` to multiple `AstronautComponent` children.

View File

@ -26,7 +26,7 @@ include ../_util-fns
[Limit service scope to a component subtree](#service-scope) [Limit service scope to a component subtree](#service-scope)
[把服务作用范围限制到一个子组件树](#service-scope) [把服务作用限制到一个子组件树](#service-scope)
[Multiple service instances (sandboxing)](#multiple-service-instances) [Multiple service instances (sandboxing)](#multiple-service-instances)
@ -303,7 +303,7 @@ figure.image-display
:marked :marked
## Limit service scope to a component subtree ## Limit service scope to a component subtree
## 把服务作用范围限制到一个组件支树 ## 把服务作用限制到一个组件支树
All injected service dependencies are singletons meaning that, All injected service dependencies are singletons meaning that,
for a given dependency injector ("injector"), there is only one instance of service. for a given dependency injector ("injector"), there is only one instance of service.
@ -334,7 +334,7 @@ figure.image-display
by providing that service *at the sub-root component for that branch*. by providing that service *at the sub-root component for that branch*.
Here we provide the `HeroService` to the `HeroesBaseComponent` by listing it in the `providers` array: Here we provide the `HeroService` to the `HeroesBaseComponent` by listing it in the `providers` array:
通过*在组件树的子级根组件*中提供服务,可以把一个被注入服务的作用范围局限在应用程序结构中的某个*分支*中。 通过*在组件树的子级根组件*中提供服务,可以把一个被注入服务的作用局限在应用程序结构中的某个*分支*中。
这里通过列入`providers`数组,在`HeroesBaseComponent`中提供了`HeroService` 这里通过列入`providers`数组,在`HeroesBaseComponent`中提供了`HeroService`
+makeExample('cb-dependency-injection/ts/app/sorted-heroes.component.ts','injection','app/sorted-heroes.component.ts (HeroesBaseComponent excerpt)') +makeExample('cb-dependency-injection/ts/app/sorted-heroes.component.ts','injection','app/sorted-heroes.component.ts (HeroesBaseComponent excerpt)')

View File

@ -322,7 +322,7 @@ include _util-fns
that it decorates. None of the decorations shown here will "leak" to other that it decorates. None of the decorations shown here will "leak" to other
classes appearing below it in the file. classes appearing below it in the file.
一个装饰器的作用范围会被限制在它所装饰的东西上,这是一个语言级特性。在上面这个例子中,就算别的类在同一个文件中紧跟着上面的类也不会有任何装饰器“泄露”到其它类。 一个装饰器的作用会被限制在它所装饰的东西上,这是一个语言级特性。在上面这个例子中,就算别的类在同一个文件中紧跟着上面的类也不会有任何装饰器“泄露”到其它类。
.alert.is-important .alert.is-important
:marked :marked

View File

@ -279,7 +279,7 @@ figure.image-display
但很明显,这个场景下我们不希望这样。我们希望每个组件都有它自己的`RestoreService`实例。 但很明显,这个场景下我们不希望这样。我们希望每个组件都有它自己的`RestoreService`实例。
在组件级别上定义(或重定义)一个提供商,将会为该组件创建一个新的服务实例。 在组件级别上定义(或重定义)一个提供商,将会为该组件创建一个新的服务实例。
我们已经为`HeroEditComponent`制造了一种“私有”`RestoreService`单例,它的作用范围被局限在了该组件的实例及其子组件中。 我们已经为`HeroEditComponent`制造了一种“私有”`RestoreService`单例,它的作用被局限在了该组件的实例及其子组件中。
<!-- <!--
## Advanced Dependency Injection in Angular 2 ## Advanced Dependency Injection in Angular 2

View File

@ -230,7 +230,7 @@ code-example(language="bash").
When we assign styles to a component they are scoped to that specific component. When we assign styles to a component they are scoped to that specific component.
Our styles will only apply to our `AppComponent` and won't "leak" to the outer HTML. Our styles will only apply to our `AppComponent` and won't "leak" to the outer HTML.
当我们把样式赋予一个组件时,它们的作用范围将仅限于该组件。 当我们把样式赋予一个组件时,它们的作用将仅限于该组件。
即:此样式只会作用于这个`AppComponent`组件而不会“泄露”到外部HTML中。 即:此样式只会作用于这个`AppComponent`组件而不会“泄露”到外部HTML中。
Our template for displaying the heroes should now look like this: Our template for displaying the heroes should now look like this: