@@ -1235,7 +1235,7 @@ ending `ElementInjector` using the visibility decorators `@Host()`,
### Visibility of provided tokens
-### 提供商令牌的可见性
+### 提供者令牌的可见性
Visibility decorators influence where the search for the injection
@@ -1572,7 +1572,7 @@ The ability to configure one or more providers at different levels
opens up useful possibilities.
For a look at the following scenarios in a working app, see the heroes use case examples.
-在不同级别配置一个或多个提供商的能力开辟了很有用的可能性。要查看正在运行的应用中的以下情况,请参阅英雄示例。
+在不同级别配置一个或多个提供者的能力开辟了很有用的可能性。要查看正在运行的应用中的以下情况,请参阅英雄示例。
### Scenario: service isolation
@@ -1718,7 +1718,7 @@ The `HeroTaxReturnComponent` has its own provider of the `HeroTaxReturnService`.
Recall that every component _instance_ has its own injector.
Providing the service at the component level ensures that _every_ instance of the component gets its own, private instance of the service, and no tax return gets overwritten.
-`HeroTaxReturnComponent` 有它自己的 `HeroTaxReturnService` 提供商。
+`HeroTaxReturnComponent` 有它自己的 `HeroTaxReturnService` 提供者。
回忆一下,每个组件的*实例*都有它自己的注入器。
在组件级提供服务可以确保组件的*每个*实例都得到一个自己的、私有的服务实例,而报税单也不会再被意外覆盖了。
@@ -1734,7 +1734,7 @@ You can review it and download it from the .
### Scenario: specialized providers
-### 场景:专门的提供商
+### 场景:专门的提供者
Another reason to re-provide a service at another level is to substitute a _more specialized_ implementation of that service, deeper in the component tree.
@@ -1745,7 +1745,7 @@ Suppose you configured the root injector (marked as A) with _generic_ providers
`CarService`, `EngineService` and `TiresService`.
考虑一个依赖于一系列服务的 Car 组件。
-假设你在根注入器(代号 A)中配置了*通用的*提供商:`CarService`、`EngineService` 和 `TiresService`。
+假设你在根注入器(代号 A)中配置了*通用的*提供者:`CarService`、`EngineService` 和 `TiresService`。
You create a car component (A) that displays a car constructed from these three generic services.
@@ -1754,11 +1754,11 @@ You create a car component (A) that displays a car constructed from these three
Then you create a child component (B) that defines its own, _specialized_ providers for `CarService` and `EngineService`
that have special capabilities suitable for whatever is going on in component (B).
-然后,你创建一个子组件(B),它为 `CarService` 和 `EngineService` 定义了自己*特有的*提供商,它们具有适用于组件 B 的特有能力。
+然后,你创建一个子组件(B),它为 `CarService` 和 `EngineService` 定义了自己*特有的*提供者,它们具有适用于组件 B 的特有能力。
Component (B) is the parent of another component (C) that defines its own, even _more specialized_ provider for `CarService`.
-组件 B 是另一个组件 C 的父组件,而组件 C 又定义了自己的,*更特殊的*`CarService` 提供商。
+组件 B 是另一个组件 C 的父组件,而组件 C 又定义了自己的,*更特殊的*`CarService` 提供者。
@@ -1768,7 +1768,7 @@ Component (B) is the parent of another component (C) that defines its own, even
Behind the scenes, each component sets up its own injector with zero, one, or more providers defined for that component itself.
-在幕后,每个组件都有自己的注入器,这个注入器带有为组件本身准备的 0 个、1 个或多个提供商。
+在幕后,每个组件都有自己的注入器,这个注入器带有为组件本身准备的 0 个、1 个或多个提供者。
When you resolve an instance of `Car` at the deepest component (C),
its injector produces an instance of `Car` resolved by injector (C) with an `Engine` resolved by injector (B) and
@@ -1790,4 +1790,4 @@ its injector produces an instance of `Car` resolved by injector (C) with an `Eng
For more information on Angular dependency injection, see the [DI Providers](guide/dependency-injection-providers) and [DI in Action](guide/dependency-injection-in-action) guides.
-要了解关于 Angular 依赖注入的更多信息,参见 [DI 提供商](guide/dependency-injection-providers)和 [DI 实战](guide/dependency-injection-in-action) 两章。
+要了解关于 Angular 依赖注入的更多信息,参见 [DI 提供者](guide/dependency-injection-providers)和 [DI 实战](guide/dependency-injection-in-action) 两章。
diff --git a/aio/content/guide/http.md b/aio/content/guide/http.md
index 75d3eb1d3d..6b8772d50b 100644
--- a/aio/content/guide/http.md
+++ b/aio/content/guide/http.md
@@ -829,7 +829,7 @@ You should provide interceptors in `AppModule` as well.
After importing the `HTTP_INTERCEPTORS` injection token from `@angular/common/http`,
write the `NoopInterceptor` provider like this:
-在从 `@angular/common/http` 中导入了 `HTTP_INTERCEPTORS` 注入令牌之后,编写如下的 `NoopInterceptor` 提供商注册语句:
+在从 `@angular/common/http` 中导入了 `HTTP_INTERCEPTORS` 注入令牌之后,编写如下的 `NoopInterceptor` 提供者注册语句:
@@ -173,7 +173,7 @@ typical characteristics, in real world apps, you may see hybrids.
Adds guard and resolver service providers to the module's providers.
- 把路由守卫和解析器的服务提供商添加到该模块的 `providers` 中。
+ 把路由守卫和解析器的服务提供者添加到该模块的 `providers` 中。
@@ -227,7 +227,7 @@ typical characteristics, in real world apps, you may see hybrids.
Service modules provide utility services such as data access and messaging. Ideally, they consist entirely of providers and have no declarations. Angular's `HttpClientModule` is a good example of a service module.
- 服务模块提供了一些工具服务,比如数据访问和消息。理论上,它们应该是完全由服务提供商组成的,不应该有可声明对象。Angular 的 `HttpClientModule` 就是一个服务模块的好例子。
+ 服务模块提供了一些工具服务,比如数据访问和消息。理论上,它们应该是完全由服务提供者组成的,不应该有可声明对象。Angular 的 `HttpClientModule` 就是一个服务模块的好例子。
The root `AppModule` is the only module that should import service modules.
@@ -259,7 +259,7 @@ typical characteristics, in real world apps, you may see hybrids.
A widget module should rarely have providers.
- 窗口部件模块很少会有服务提供商。
+ 窗口部件模块很少会有服务提供者。
Import widget modules in any module whose component templates need the widgets.
@@ -298,7 +298,7 @@ The following table summarizes the key characteristics of each feature module gr
Providers
- 提供商 `providers`
+ 提供者 `providers`
@@ -553,4 +553,4 @@ You may also be interested in the following:
* [Providers](guide/providers).
- [服务提供商](guide/providers)。
+ [服务提供者](guide/providers)。
diff --git a/aio/content/guide/ngmodule-api.md b/aio/content/guide/ngmodule-api.md
index 1bb20d799c..25ee255ca2 100644
--- a/aio/content/guide/ngmodule-api.md
+++ b/aio/content/guide/ngmodule-api.md
@@ -146,12 +146,12 @@ The following table summarizes the `@NgModule` metadata properties.
A list of dependency-injection providers.
- 依赖注入提供商的列表。
+ 依赖注入提供者的列表。
Angular registers these providers with the NgModule's injector.
If it is the NgModule used for bootstrapping then it is the root injector.
- Angular 会使用该模块的注入器注册这些提供商。
+ Angular 会使用该模块的注入器注册这些提供者。
如果该模块是启动模块,那就会使用根注入器。
These services become available for injection into any component, directive, pipe or service which is a child of this injector.
@@ -177,7 +177,7 @@ The following table summarizes the `@NgModule` metadata properties.
For more information on injector hierarchy and scoping, see [Providers](guide/providers) and the [DI Guide](guide/dependency-injection).
- 要深入了解关于多级注入器及其作用域,参见[服务提供商](guide/providers)。
+ 要深入了解关于多级注入器及其作用域,参见[服务提供者](guide/providers)。
@@ -380,7 +380,7 @@ You may also be interested in the following:
* [Providers](guide/providers).
- [服务提供商](guide/providers)。
+ [服务提供者](guide/providers)。
* [Types of Feature Modules](guide/module-types).
diff --git a/aio/content/guide/ngmodule-faq.md b/aio/content/guide/ngmodule-faq.md
index 4d9dbd89c9..030b8da3e9 100644
--- a/aio/content/guide/ngmodule-faq.md
+++ b/aio/content/guide/ngmodule-faq.md
@@ -173,7 +173,7 @@ should import `BrowserModule` from `@angular/platform-browser`.
`BrowserModule` provides services that are essential to launch and run a browser app.
-`BrowserModule` 提供了启动和运行浏览器应用的那些基本的服务提供商。
+`BrowserModule` 提供了启动和运行浏览器应用的那些基本的服务提供者。
`BrowserModule` also re-exports `CommonModule` from `@angular/common`,
which means that components in the `AppModule` module also have access to
@@ -187,7 +187,7 @@ They need the common directives. They don't need to re-install the app-wide prov
在其它任何模块中都*不要导入*`BrowserModule`。
*特性模块*和*惰性加载模块*应该改成导入 `CommonModule`。
-它们需要通用的指令。它们不需要重新初始化全应用级的提供商。
+它们需要通用的指令。它们不需要重新初始化全应用级的提供者。
Importing `CommonModule` also frees feature modules for use on _any_ target platform, not just browsers.
@@ -278,7 +278,7 @@ Its only purpose is to add http service providers to the application as a whole.
纯服务模块没有公开(导出)的声明。
例如,没必要重新导出 `HttpClientModule`,因为它不导出任何东西。
- 它唯一的用途是一起把 http 的那些服务提供商添加到应用中。
+ 它唯一的用途是一起把 http 的那些服务提供者添加到应用中。
@@ -319,7 +319,7 @@ Its only purpose is to add http service providers to the application as a whole.
不要费心去导出纯服务类。
纯服务类的模块不会导出任何可供其它模块使用的[可声明类](guide/ngmodule-faq#q-declarable)。
例如,不用重新导出 `HttpClientModule`,因为它没有导出任何东西。
-它唯一的用途是把那些 http 服务提供商一起添加到应用中。
+它唯一的用途是把那些 http 服务提供者一起添加到应用中。
@@ -329,7 +329,7 @@ Its only purpose is to add http service providers to the application as a whole.
The `forRoot()` static method is a convention that makes it easy for developers to configure services and providers that are intended to be singletons. A good example of `forRoot()` is the `RouterModule.forRoot()` method.
-静态方法 `forRoot()` 是一个约定,它可以让开发人员更轻松的配置模块的想要单例使用的服务及其提供商。`RouterModule.forRoot()` 就是一个很好的例子。
+静态方法 `forRoot()` 是一个约定,它可以让开发人员更轻松的配置模块的想要单例使用的服务及其提供者。`RouterModule.forRoot()` 就是一个很好的例子。
Apps pass a `Routes` object to `RouterModule.forRoot()` in order to configure the app-wide `Router` service with routes.
`RouterModule.forRoot()` returns a [ModuleWithProviders](api/core/ModuleWithProviders).
@@ -363,29 +363,29 @@ configure services in root and feature modules respectively.
Follow this convention when you write similar modules with configurable service providers.
-当你写类似的需要可配置的服务提供商时,请遵循这个约定。
+当你写类似的需要可配置的服务提供者时,请遵循这个约定。
## Why is a service provided in a feature module visible everywhere?
-## 为什么服务提供商在特性模块中的任何地方都是可见的?
+## 为什么服务提供者在特性模块中的任何地方都是可见的?
Providers listed in the `@NgModule.providers` of a bootstrapped module have application scope.
Adding a service provider to `@NgModule.providers` effectively publishes the service to the entire application.
-列在引导模块的 `@NgModule.providers` 中的服务提供商具有**全应用级作用域**。
-往 `NgModule.providers` 中添加服务提供商将导致该服务被发布到整个应用中。
+列在引导模块的 `@NgModule.providers` 中的服务提供者具有**全应用级作用域**。
+往 `NgModule.providers` 中添加服务提供者将导致该服务被发布到整个应用中。
When you import an NgModule,
Angular adds the module's service providers (the contents of its `providers` list)
to the application root injector.
-当你导入一个模块时,Angular 就会把该模块的服务提供商(也就是它的 `providers` 列表中的内容)加入该应用的*根注入器*中。
+当你导入一个模块时,Angular 就会把该模块的服务提供者(也就是它的 `providers` 列表中的内容)加入该应用的*根注入器*中。
This makes the provider visible to every class in the application that knows the provider's lookup token, or name.
-这会让该提供商对应用中所有知道该提供商令牌(token)的类都可见。
+这会让该提供者对应用中所有知道该提供者令牌(token)的类都可见。
Extensibility through NgModule imports is a primary goal of the NgModule system.
Merging NgModule providers into the application injector
@@ -393,7 +393,7 @@ makes it easy for a module library to enrich the entire application with new ser
By adding the `HttpClientModule` once, every application component can make HTTP requests.
通过 NgModule 导入来实现可扩展性是 NgModule 体系的主要设计目标。
-把 NgModule 的提供商并入应用程序的注入器可以让库模块使用新的服务来强化应用程序变得更容易。
+把 NgModule 的提供者并入应用程序的注入器可以让库模块使用新的服务来强化应用程序变得更容易。
只要添加一次 `HttpClientModule`,那么应用中的每个组件就都可以发起 Http 请求了。
However, this might feel like an unwelcome surprise if you expect the module's services
@@ -415,12 +415,12 @@ To limit access to a service, consider lazy loading the NgModule that provides t
## Why is a service provided in a lazy-loaded module visible only to that module?
-## 为什么在惰性加载模块中声明的服务提供商只对该模块自身可见?
+## 为什么在惰性加载模块中声明的服务提供者只对该模块自身可见?
Unlike providers of the modules loaded at launch,
providers of lazy-loaded modules are *module-scoped*.
-和启动时就加载的模块中的提供商不同,惰性加载模块中的提供商是*局限于模块*的。
+和启动时就加载的模块中的提供者不同,惰性加载模块中的提供者是*局限于模块*的。
When the Angular router lazy-loads a module, it creates a new execution context.
That [context has its own injector](guide/ngmodule-faq#q-why-child-injector "Why Angular creates a child injector"),
@@ -431,13 +431,13 @@ which is a direct child of the application injector.
The router adds the lazy module's providers and the providers of its imported NgModules to this child injector.
-路由器把该惰性加载模块的提供商和它导入的模块的提供商添加到这个子注入器中。
+路由器把该惰性加载模块的提供者和它导入的模块的提供者添加到这个子注入器中。
These providers are insulated from changes to application providers with the same lookup token.
When the router creates a component within the lazy-loaded context,
Angular prefers service instances created from these providers to the service instances of the application root injector.
-这些提供商不会被拥有相同令牌的应用级别提供商的变化所影响。
+这些提供者不会被拥有相同令牌的应用级别提供者的变化所影响。
当路由器在惰性加载环境中创建组件时,Angular 优先使用惰性加载模块中的服务实例,而不是来自应用的根注入器的。
@@ -449,18 +449,18 @@ Angular prefers service instances created from these providers to the service in
When two imported modules, loaded at the same time, list a provider with the same token,
the second module's provider "wins". That's because both providers are added to the same injector.
-当同时加载了两个导入的模块,它们都列出了使用同一个令牌的提供商时,后导入的模块会“获胜”,这是因为这两个提供商都被添加到了同一个注入器中。
+当同时加载了两个导入的模块,它们都列出了使用同一个令牌的提供者时,后导入的模块会“获胜”,这是因为这两个提供者都被添加到了同一个注入器中。
When Angular looks to inject a service for that token,
it creates and delivers the instance created by the second provider.
-当 Angular 尝试根据令牌注入服务时,它使用第二个提供商来创建并交付服务实例。
+当 Angular 尝试根据令牌注入服务时,它使用第二个提供者来创建并交付服务实例。
_Every_ class that injects this service gets the instance created by the second provider.
Even classes declared within the first module get the instance created by the second provider.
-*每个*注入了该服务的类获得的都是由第二个提供商创建的实例。
-即使是声明在第一个模块中的类,它取得的实例也是来自第二个提供商的。
+*每个*注入了该服务的类获得的都是由第二个提供者创建的实例。
+即使是声明在第一个模块中的类,它取得的实例也是来自第二个提供者的。
If NgModule A provides a service for token 'X' and imports an NgModule B
that also provides a service for token 'X', then NgModule A's service definition "wins".
@@ -490,13 +490,13 @@ that is, they are available for injection throughout the application.
Imported providers are easily replaced by providers from another imported NgModule.
Such replacement might be by design. It could be unintentional and have adverse consequences.
-导入的提供商很容易被由其它导入模块中的提供商替换掉。
+导入的提供者很容易被由其它导入模块中的提供者替换掉。
这虽然是故意这样设计的,但是也可能引起意料之外的结果。
As a general rule, import modules with providers _exactly once_, preferably in the application's _root module_.
That's also usually the best place to configure, wrap, and override them.
-作为一个通用的规则,应该*只导入一次*带提供商的模块,最好在应用的*根模块*中。
+作为一个通用的规则,应该*只导入一次*带提供者的模块,最好在应用的*根模块*中。
那里也是配置、包装和改写这些服务的最佳位置。
Suppose a module requires a customized `HttpBackend` that adds a special header for all Http requests.
@@ -505,7 +505,7 @@ or merely imports the `HttpClientModule`, it could override this module's `HttpB
losing the special header. The server will reject http requests from this module.
假设模块需要一个定制过的 `HttpBackend`,它为所有的 Http 请求添加一个特别的请求头。
- 如果应用中其它地方的另一个模块也定制了 `HttpBackend` 或仅仅导入了 `HttpClientModule`,它就会改写当前模块的 `HttpBackend` 提供商,丢掉了这个特别的请求头。
+ 如果应用中其它地方的另一个模块也定制了 `HttpBackend` 或仅仅导入了 `HttpClientModule`,它就会改写当前模块的 `HttpBackend` 提供者,丢掉了这个特别的请求头。
这样服务器就会拒绝来自该模块的请求。
To avoid this problem, import the `HttpClientModule` only in the `AppModule`, the application _root module_.
@@ -514,7 +514,7 @@ To avoid this problem, import the `HttpClientModule` only in the `AppModule`, th
If you must guard against this kind of "provider corruption", *don't rely on a launch-time module's `providers`.*
-如果你必须防范这种“提供商腐化”现象,那就*不要依赖于“启动时加载”模块的 `providers`*。
+如果你必须防范这种“提供者腐化”现象,那就*不要依赖于“启动时加载”模块的 `providers`*。
Load the module lazily if you can.
Angular gives a [lazy-loaded module](guide/ngmodule-faq#q-lazy-loaded-module-provider-visibility) its own child injector.
@@ -522,7 +522,7 @@ The module's providers are visible only within the component tree created with t
只要可能,就让模块惰性加载。
Angular 给了[惰性加载模块](guide/ngmodule-faq#q-lazy-loaded-module-provider-visibility)自己的子注入器。
-该模块中的提供商只对由该注入器创建的组件树可见。
+该模块中的提供者只对由该注入器创建的组件树可见。
If you must load the module eagerly, when the application starts,
*provide the service in a component instead.*
@@ -539,7 +539,7 @@ Recall that Angular creates a child injector for each component instance and pop
with the component's own providers.
那就创建一个“顶层组件”来扮演该模块中所有组件的根。
-把这个自定义的 `HttpBackend` 提供商添加到这个顶层组件的 `providers` 列表中,而不是该模块的 `providers` 中。
+把这个自定义的 `HttpBackend` 提供者添加到这个顶层组件的 `providers` 列表中,而不是该模块的 `providers` 中。
回忆一下,Angular 会为每个组件实例创建一个子注入器,并使用组件自己的 `providers` 来配置这个注入器。
When a child of this component asks for the `HttpBackend` service,
@@ -571,16 +571,16 @@ Though you can limit access to a service by providing it in a lazy loaded module
## Should I add application-wide providers to the root `AppModule` or the root `AppComponent`?
-## 我应该把全应用级提供商添加到根模块 `AppModule` 中还是根组件 `AppComponent` 中?
+## 我应该把全应用级提供者添加到根模块 `AppModule` 中还是根组件 `AppComponent` 中?
Define application-wide providers by specifying `providedIn: 'root'` on its `@Injectable()` decorator (in the case of services) or at `InjectionToken` construction (in the case where tokens are provided). Providers that are created this way automatically are made available to the entire application and don't need to be listed in any module.
-通过在服务的 `@Injectable()` 装饰器中(例如服务)指定 `providedIn: 'root'` 来定义全应用级提供商,或者 `InjectionToken` 的构造器(例如提供令牌的地方),都可以定义全应用级提供商。
-通过这种方式创建的服务提供商会自动在整个应用中可用,而不用把它列在任何模块中。
+通过在服务的 `@Injectable()` 装饰器中(例如服务)指定 `providedIn: 'root'` 来定义全应用级提供者,或者 `InjectionToken` 的构造器(例如提供令牌的地方),都可以定义全应用级提供者。
+通过这种方式创建的服务提供者会自动在整个应用中可用,而不用把它列在任何模块中。
If a provider cannot be configured in this way (perhaps because it has no sensible default value), then register application-wide providers in the root `AppModule`, not in the `AppComponent`.
-如果某个提供商不能用这种方式配置(可能因为它没有有意义的默认值),那就在根模块 `AppModule` 中注册这些全应用级服务,而不是在 `AppComponent` 中。
+如果某个提供者不能用这种方式配置(可能因为它没有有意义的默认值),那就在根模块 `AppModule` 中注册这些全应用级服务,而不是在 `AppComponent` 中。
Lazy-loaded modules and their components can inject `AppModule` services;
they can't inject `AppComponent` services.
@@ -595,7 +595,7 @@ from components outside the `AppComponent` tree. This is a rare use case.
More generally, [prefer registering providers in NgModules](guide/ngmodule-faq#q-component-or-module) to registering in components.
-更一般地说,[优先把提供商注册进模块中](guide/ngmodule-faq#q-component-or-module),而不是组件中。
+更一般地说,[优先把提供者注册进模块中](guide/ngmodule-faq#q-component-or-module),而不是组件中。
Discussion
@@ -605,8 +605,8 @@ Angular registers all startup module providers with the application root injecto
The services that root injector providers create have application scope, which
means they are available to the entire application.
-Angular 把所有启动期模块的提供商都注册进了应用的根注入器中。
-这些服务是由根注入器中的提供商创建的,并且在整个应用中都可用。
+Angular 把所有启动期模块的提供者都注册进了应用的根注入器中。
+这些服务是由根注入器中的提供者创建的,并且在整个应用中都可用。
它们具有*应用级作用域*。
Certain services, such as the `Router`, only work when you register them in the application root injector.
@@ -617,7 +617,7 @@ By contrast, Angular registers `AppComponent` providers with the `AppComponent`'
`AppComponent` services are available only to that component and its component tree.
They have component scope.
-相反,Angular 使用 `AppComponent` 自己的注入器注册了 `AppComponent` 的提供商。
+相反,Angular 使用 `AppComponent` 自己的注入器注册了 `AppComponent` 的提供者。
`AppComponent` 服务只在该组件及其子组件树中才能使用。
它们具有*组件级作用域*。
@@ -637,24 +637,24 @@ This means that lazy-loaded modules can't reach them.
## Should I add other providers to a module or a component?
-## 我应该把其它提供商注册到模块中还是组件中?
+## 我应该把其它提供者注册到模块中还是组件中?
Providers should be configured using `@Injectable` syntax. If possible, they should be provided in the application root (`providedIn: 'root'`). Services that are configured this way are lazily loaded if they are only used from a lazily loaded context.
-提供商应该使用 `@Injectable` 语法进行配置。只要可能,就应该把它们在应用的根注入器中提供(`providedIn: 'root'`)。
+提供者应该使用 `@Injectable` 语法进行配置。只要可能,就应该把它们在应用的根注入器中提供(`providedIn: 'root'`)。
如果它们只被惰性加载的上下文中使用,那么这种方式配置的服务就是惰性加载的。
If it's the consumer's decision whether a provider is available application-wide or not,
then register providers in modules (`@NgModule.providers`) instead of registering in components (`@Component.providers`).
-如果要由消费方来决定是否把它作为全应用级提供商,那么就要在模块中(`@NgModule.providers`)注册提供商,而不是组件中(`@Component.providers`)。
+如果要由消费方来决定是否把它作为全应用级提供者,那么就要在模块中(`@NgModule.providers`)注册提供者,而不是组件中(`@Component.providers`)。
Register a provider with a component when you _must_ limit the scope of a service instance
to that component and its component tree.
Apply the same reasoning to registering a provider with a directive.
-当你*必须*把服务实例的范围限制到某个组件及其子组件树时,就把提供商注册到该组件中。
-指令的提供商也同样照此处理。
+当你*必须*把服务实例的范围限制到某个组件及其子组件树时,就把提供者注册到该组件中。
+指令的提供者也同样照此处理。
For example, an editing component that needs a private copy of a caching service should register
the service with the component.
@@ -704,7 +704,7 @@ Now consider a lazy loaded module that also provides a service called `UserServi
When the router lazy loads a module, it creates a child injector and registers the `UserService`
provider with that child injector. The child injector is _not_ the root injector.
-当路由器准备惰性加载 `HeroModule` 的时候,它会创建一个子注入器,并且把 `UserService` 的提供商注册到那个子注入器中。子注入器和根注入器是*不同*的。
+当路由器准备惰性加载 `HeroModule` 的时候,它会创建一个子注入器,并且把 `UserService` 的提供者注册到那个子注入器中。子注入器和根注入器是*不同*的。
When Angular creates a lazy component for that module and injects `UserService`,
it finds a `UserService` provider in the lazy module's _child injector_
@@ -713,7 +713,7 @@ This is an entirely different `UserService` instance
than the app-wide singleton version that Angular injected in one of the eagerly loaded components.
当 Angular 创建一个惰性加载的 `HeroComponent` 时,它必须注入一个 `UserService`。
-这次,它会从惰性加载模块的*子注入器*中查找 `UserService` 的提供商,并用它创建一个 `UserService` 的新实例。
+这次,它会从惰性加载模块的*子注入器*中查找 `UserService` 的提供者,并用它创建一个 `UserService` 的新实例。
这个 `UserService` 实例与 Angular 在主动加载的组件中注入的那个全应用级单例对象截然不同。
This scenario causes your app to create a new instance every time, instead of using the singleton.
@@ -739,8 +739,8 @@ I'd like to see the error so I can include it.-->
Angular adds `@NgModule.providers` to the application root injector, unless the NgModule is lazy-loaded.
For a lazy-loaded NgModule, Angular creates a _child injector_ and adds the module's providers to the child injector.
-Angular 会把 `@NgModule.providers` 中的提供商添加到应用的根注入器中……
-除非该模块是惰性加载的,这种情况下,Angular 会创建一*子注入器*,并且把该模块的提供商添加到这个子注入器中。
+Angular 会把 `@NgModule.providers` 中的提供者添加到应用的根注入器中……
+除非该模块是惰性加载的,这种情况下,Angular 会创建一*子注入器*,并且把该模块的提供者添加到这个子注入器中。
This means that an NgModule behaves differently depending on whether it's loaded during application start
or lazy-loaded later. Neglecting that difference can lead to [adverse consequences](guide/ngmodule-faq#q-why-bad).
@@ -749,22 +749,22 @@ or lazy-loaded later. Neglecting that difference can lead to [adverse consequenc
Why doesn't Angular add lazy-loaded providers to the app root injector as it does for eagerly loaded NgModules?
-为什么 Angular 不能像主动加载模块那样把惰性加载模块的提供商也添加到应用程序的根注入器中呢?为什么会出现这种不一致?
+为什么 Angular 不能像主动加载模块那样把惰性加载模块的提供者也添加到应用程序的根注入器中呢?为什么会出现这种不一致?
The answer is grounded in a fundamental characteristic of the Angular dependency-injection system.
An injector can add providers _until it's first used_.
Once an injector starts creating and delivering services, its provider list is frozen; no new providers are allowed.
归根结底,这来自于 Angular 依赖注入系统的一个基本特征:
-在注入器还没有被第一次使用之前,可以不断为其添加提供商。
-一旦注入器已经创建和开始交付服务,它的提供商列表就被冻结了,不再接受新的提供商。
+在注入器还没有被第一次使用之前,可以不断为其添加提供者。
+一旦注入器已经创建和开始交付服务,它的提供者列表就被冻结了,不再接受新的提供者。
When an applications starts, Angular first configures the root injector with the providers of all eagerly loaded NgModules
_before_ creating its first component and injecting any of the provided services.
Once the application begins, the app root injector is closed to new providers.
-当应用启动时,Angular 会首先使用所有主动加载模块中的提供商来配置根注入器,这发生在它创建第一个组件以及注入任何服务之前。
-一旦应用开始工作,应用的根注入器就不再接受新的提供商了。
+当应用启动时,Angular 会首先使用所有主动加载模块中的提供者来配置根注入器,这发生在它创建第一个组件以及注入任何服务之前。
+一旦应用开始工作,应用的根注入器就不再接受新的提供者了。
Time passes and application logic triggers lazy loading of an NgModule.
Angular must add the lazy-loaded module's providers to an injector somewhere.
@@ -772,8 +772,8 @@ It can't add them to the app root injector because that injector is closed to ne
So Angular creates a new child injector for the lazy-loaded module context.
之后,应用逻辑开始惰性加载某个模块。
-Angular 必须把这个惰性加载模块中的提供商添加到*某个*注入器中。
-但是它无法将它们添加到应用的根注入器中,因为根注入器已经不再接受新的提供商了。
+Angular 必须把这个惰性加载模块中的提供者添加到*某个*注入器中。
+但是它无法将它们添加到应用的根注入器中,因为根注入器已经不再接受新的提供者了。
于是,Angular 在惰性加载模块的上下文中创建了一个新的子注入器。
diff --git a/aio/content/guide/ngmodule-vs-jsmodule.md b/aio/content/guide/ngmodule-vs-jsmodule.md
index bdb8504d0d..f2f4b3966f 100644
--- a/aio/content/guide/ngmodule-vs-jsmodule.md
+++ b/aio/content/guide/ngmodule-vs-jsmodule.md
@@ -98,7 +98,7 @@ it owns or imports from other modules. It doesn't declare or export any other ki
* Unlike JavaScript modules, an NgModule can extend the _entire_ application with services
by adding providers to the `@NgModule.providers` list.
- 与 JavaScript 模块不同,NgModule 可以通过把服务提供商加到 `@NgModule.providers` 列表中,来用服务扩展*整个*应用。
+ 与 JavaScript 模块不同,NgModule 可以通过把服务提供者加到 `@NgModule.providers` 列表中,来用服务扩展*整个*应用。
@@ -120,4 +120,4 @@ For more information on NgModules, see:
* [Providers](guide/providers).
- [服务提供商](guide/providers)。
+ [服务提供者](guide/providers)。
diff --git a/aio/content/guide/ngmodules.md b/aio/content/guide/ngmodules.md
index 5aaee39a5e..aa3d7ac270 100644
--- a/aio/content/guide/ngmodules.md
+++ b/aio/content/guide/ngmodules.md
@@ -13,7 +13,7 @@ making some of them public, through the `exports` property, so that external com
NgModule 是一个带有 `@NgModule` 装饰器的类。
`@NgModule` 的参数是一个元数据对象,用于描述如何编译组件的模板,以及如何在运行时创建注入器。
它会标出该模块自己的组件、指令和管道,通过 `exports` 属性公开其中的一部分,以便外部组件使用它们。
-`NgModule` 还能把一些服务提供商添加到应用的依赖注入器中。
+`NgModule` 还能把一些服务提供者添加到应用的依赖注入器中。
For an example app showcasing all the techniques that NgModules related pages
cover, see the . For explanations on the individual techniques, visit the relevant NgModule pages under the NgModules
@@ -130,7 +130,7 @@ You may also be interested in the following:
* [Providers](guide/providers).
- [服务提供商](guide/providers)。
+ [服务提供者](guide/providers)。
* [Types of NgModules](guide/module-types).
diff --git a/aio/content/guide/npm-packages.md b/aio/content/guide/npm-packages.md
index c2da2c34ed..1bce38e266 100644
--- a/aio/content/guide/npm-packages.md
+++ b/aio/content/guide/npm-packages.md
@@ -122,7 +122,7 @@ Package name | Description
[**@angular/
platform‑browser**](api/platform-browser) | Everything DOM and browser related, especially the pieces that help render into the DOM. This package also includes the `bootstrapModuleFactory()` method for bootstrapping applications for production builds that pre-compile with [AOT](guide/aot-compiler).
[**@angular/
platform‑browser**](api/platform-browser) | 与 DOM 和浏览器有关的一切,特别是那些帮助往 DOM 中渲染的部分。这个包中还包括 `bootstrapModuleFactory()` 方法,该方法可以使用 [AOT](guide/aot-compiler) 编译器构建的生产环境发布包来引导应用。
[**@angular/
platform‑browser‑dynamic**](api/platform-browser-dynamic) | Includes [providers](api/core/Provider) and methods to compile and run the app on the client using the [JIT compiler](guide/aot-compiler).
-[**@angular/
platform‑browser‑dynamic**](api/platform-browser-dynamic) | 包含那些用来在 [JIT 编译器](guide/aot-compiler)的客户端上编译并运行应用的[提供商](api/core/Provider)和方法。
+[**@angular/
platform‑browser‑dynamic**](api/platform-browser-dynamic) | 包含那些用来在 [JIT 编译器](guide/aot-compiler)的客户端上编译并运行应用的[提供者](api/core/Provider)和方法。
[**@angular/router**](api/router) | The router module navigates among your app pages when the browser URL changes. For more information, see [Routing and Navigation](guide/router).
[**@angular/router**](api/router) | 当浏览器的 URL 变化时,路由器模块可以在应用的页面之间进行导航。欲知详情,参见[路由与导航](guide/router)。
diff --git a/aio/content/guide/providers.md b/aio/content/guide/providers.md
index 6181a09dbe..34b0e08bb5 100644
--- a/aio/content/guide/providers.md
+++ b/aio/content/guide/providers.md
@@ -1,10 +1,10 @@
# Providers
-# 服务提供商
+# 服务提供者
A provider is an instruction to the [Dependency Injection](/guide/dependency-injection) system on how to obtain a value for a dependency. Most of the time, these dependencies are services that you create and provide.
-提供商就是一本说明书,用来指导[依赖注入](/guide/dependency-injection)系统该如何获取某个依赖的值。
+提供者就是一本说明书,用来指导[依赖注入](/guide/dependency-injection)系统该如何获取某个依赖的值。
大多数情况下,这些依赖就是你要创建和提供的那些服务。
For the final sample app using the provider that this page describes,
@@ -38,16 +38,16 @@ You can now inject `UserService` anywhere in your application.
The service itself is a class that the CLI generated and that's decorated with `@Injectable()`. By default, this decorator has a `providedIn` property, which creates a provider for the service. In this case, `providedIn: 'root'` specifies that Angular should provide the service in the root injector.
-该服务本身是 CLI 创建的一个类,并且加上了 `@Injectable()` 装饰器。默认情况下,该装饰器是用 `providedIn` 属性进行配置的,它会为该服务创建一个提供商。在这个例子中,`providedIn: 'root'` 指定 Angular 应该在根注入器中提供该服务。
+该服务本身是 CLI 创建的一个类,并且加上了 `@Injectable()` 装饰器。默认情况下,该装饰器是用 `providedIn` 属性进行配置的,它会为该服务创建一个提供者。在这个例子中,`providedIn: 'root'` 指定 Angular 应该在根注入器中提供该服务。
## Provider scope
-## 提供商的作用域
+## 提供者的作用域
When you add a service provider to the root application injector, it’s available throughout the app. Additionally, these providers are also available to all the classes in the app as long they have the lookup token.
-当你把服务提供商添加到应用的根注入器中时,它就在整个应用程序中可用了。
-另外,这些服务提供商也同样对整个应用中的类是可用的 —— 只要它们有供查找用的服务令牌。
+当你把服务提供者添加到应用的根注入器中时,它就在整个应用程序中可用了。
+另外,这些服务提供者也同样对整个应用中的类是可用的 —— 只要它们有供查找用的服务令牌。
You should always provide your service in the root injector unless there is a case where you want the service to be available only if the consumer imports a particular `@NgModule`.
@@ -65,17 +65,17 @@ It's also possible to specify that a service should be provided in a particular
The example above shows the preferred way to provide a service in a module. This method is preferred because it enables tree-shaking of the service if nothing injects it. If it's not possible to specify in the service which module should provide it, you can also declare a provider for the service within the module:
-上面的例子展示的就是在模块中提供服务的首选方式。之所以推荐该方式,是因为当没有人注入它时,该服务就可以被摇树优化掉。如果没办法指定哪个模块该提供这个服务,你也可以在那个模块中为该服务声明一个提供商:
+上面的例子展示的就是在模块中提供服务的首选方式。之所以推荐该方式,是因为当没有人注入它时,该服务就可以被摇树优化掉。如果没办法指定哪个模块该提供这个服务,你也可以在那个模块中为该服务声明一个提供者:
## Limiting provider scope by lazy loading modules
-## 使用惰性加载模块限制提供商的作用域
+## 使用惰性加载模块限制提供者的作用域
In the basic CLI-generated app, modules are eagerly loaded which means that they are all loaded when the app launches. Angular uses an injector system to make things available between modules. In an eagerly loaded app, the root application injector makes all of the providers in all of the modules available throughout the app.
-在 CLI 生成的基本应用中,模块是急性加载的,这意味着它们都是由本应用启动的,Angular 会使用一个依赖注入体系来让一切服务都在模块间有效。对于急性加载式应用,应用中的根注入器会让所有服务提供商都对整个应用有效。
+在 CLI 生成的基本应用中,模块是急性加载的,这意味着它们都是由本应用启动的,Angular 会使用一个依赖注入体系来让一切服务都在模块间有效。对于急性加载式应用,应用中的根注入器会让所有服务提供者都对整个应用有效。
This behavior necessarily changes when you use lazy loading. Lazy loading is when you load modules only when you need them; for example, when routing. They aren’t loaded right away like with eagerly loaded modules. This means that any services listed in their provider arrays aren’t available because the root injector doesn’t know about these modules.
@@ -87,7 +87,7 @@ This behavior necessarily changes when you use lazy loading. Lazy loading is whe
When the Angular router lazy-loads a module, it creates a new injector. This injector is a child of the root application injector. Imagine a tree of injectors; there is a single root injector and then a child injector for each lazy loaded module. The router adds all of the providers from the root injector to the child injector. When the router creates a component within the lazy-loaded context, Angular prefers service instances created from these providers to the service instances of the application root injector.
-当 Angular 的路由器惰性加载一个模块时,它会创建一个新的注入器。这个注入器是应用的根注入器的一个子注入器。想象一棵注入器树,它有唯一的根注入器,而每一个惰性加载模块都有一个自己的子注入器。路由器会把根注入器中的所有提供商添加到子注入器中。如果路由器在惰性加载时创建组件, Angular 会更倾向于使用从这些提供商中创建的服务实例,而不是来自应用的根注入器的服务实例。
+当 Angular 的路由器惰性加载一个模块时,它会创建一个新的注入器。这个注入器是应用的根注入器的一个子注入器。想象一棵注入器树,它有唯一的根注入器,而每一个惰性加载模块都有一个自己的子注入器。路由器会把根注入器中的所有提供者添加到子注入器中。如果路由器在惰性加载时创建组件, Angular 会更倾向于使用从这些提供者中创建的服务实例,而不是来自应用的根注入器的服务实例。
Any component created within a lazy loaded module’s context, such as by router navigation, gets the local instance of the service, not the instance in the root application injector. Components in external modules continue to receive the instance created for the application root.
@@ -99,7 +99,7 @@ Though you can provide services by lazy loading modules, not all services can be
## Limiting provider scope with components
-## 使用组件限定服务提供商的作用域
+## 使用组件限定服务提供者的作用域
Another way to limit provider scope is by adding the service you want to limit to the component’s
`providers` array. Component providers and NgModule providers are independent of each other. This
@@ -107,7 +107,7 @@ method is helpful when you want to eagerly load a module that needs a service al
Providing a service in the component limits the service only to that component (other components in
the same module can’t access it).
-另一种限定提供商作用域的方式是把要限定的服务添加到组件的 `providers` 数组中。组件中的提供商和 NgModule 中的提供商是彼此独立的。
+另一种限定提供者作用域的方式是把要限定的服务添加到组件的 `providers` 数组中。组件中的提供者和 NgModule 中的提供者是彼此独立的。
当你要急性加载一个自带了全部所需服务的模块时,这种方式是有帮助的。
在组件中提供服务,会限定该服务只能在该组件中有效(同一模块中的其它组件不能访问它)。
@@ -123,13 +123,13 @@ Generally, provide services the whole app needs in the root module and scope ser
The router works at the root level so if you put providers in a component, even `AppComponent`, lazy loaded modules, which rely on the router, can’t see them.
-路由器工作在根级,所以如果你把服务提供商放进组件(即使是 `AppComponent`)中,那些依赖于路由器的惰性加载模块,将无法看到它们。
+路由器工作在根级,所以如果你把服务提供者放进组件(即使是 `AppComponent`)中,那些依赖于路由器的惰性加载模块,将无法看到它们。
Register a provider with a component when you must limit a service instance to a component and its component tree, that is, its child components. For example, a user editing component, `UserEditorComponent`, that needs a private copy of a caching `UserService` should register the `UserService` with the `UserEditorComponent`. Then each new instance of the `UserEditorComponent` gets its own cached service instance.
-当你必须把一个服务实例的作用域限定到组件及其组件树中时,可以使用组件注册一个服务提供商。
+当你必须把一个服务实例的作用域限定到组件及其组件树中时,可以使用组件注册一个服务提供者。
比如,用户编辑组件 `UserEditorComponent`,它需要一个缓存 `UserService` 实例,那就应该把 `UserService` 注册进 `UserEditorComponent` 中。
然后,每个 `UserEditorComponent` 的实例都会获取它自己的缓存服务实例。
@@ -153,7 +153,7 @@ You may also be interested in:
* [Tree-shakable Providers](guide/dependency-injection-providers#tree-shakable-providers).
- [可摇树优化的服务提供商](guide/dependency-injection-providers#tree-shakable-providers)。
+ [可摇树优化的服务提供者](guide/dependency-injection-providers#tree-shakable-providers)。
* [NgModule FAQ](guide/ngmodule-faq).
diff --git a/aio/content/guide/reactive-forms.md b/aio/content/guide/reactive-forms.md
index 8a0f08853a..9900279b25 100644
--- a/aio/content/guide/reactive-forms.md
+++ b/aio/content/guide/reactive-forms.md
@@ -439,7 +439,7 @@ Import the `FormBuilder` class from the `@angular/forms` package.
The `FormBuilder` service is an injectable provider that is provided with the reactive forms module. Inject this dependency by adding it to the component constructor.
-`FormBuilder` 是一个可注入的服务提供商,它是由 `ReactiveFormModule` 提供的。只要把它添加到组件的构造函数中就可以注入这个依赖。
+`FormBuilder` 是一个可注入的服务提供者,它是由 `ReactiveFormModule` 提供的。只要把它添加到组件的构造函数中就可以注入这个依赖。
diff --git a/aio/content/guide/route-animations.md b/aio/content/guide/route-animations.md
index 3b4b656dfc..4c68fb8df3 100644
--- a/aio/content/guide/route-animations.md
+++ b/aio/content/guide/route-animations.md
@@ -74,7 +74,7 @@ Use the `RouterModule.forRoot` method to define a set of routes. Also, import th
**Note:** Use the `RouterModule.forRoot` method in the root module, `AppModule`, to register top-level application routes and providers. For feature modules, call the `RouterModule.forChild` method to register additional routes.
-**注意:**在根模块 `AppModule` 中使用 `RouterModule.forRoot` 方法来注册一些顶层应用路由和提供商。对于特性模块,调用 `RouterModule.forChild` 方法来注册其它路由。
+**注意:**在根模块 `AppModule` 中使用 `RouterModule.forRoot` 方法来注册一些顶层应用路由和提供者。对于特性模块,调用 `RouterModule.forChild` 方法来注册其它路由。
diff --git a/aio/content/guide/router.md b/aio/content/guide/router.md
index e6f7ab88da..f2d2787152 100644
--- a/aio/content/guide/router.md
+++ b/aio/content/guide/router.md
@@ -885,7 +885,7 @@ Here are the key `Router` terms and their meanings:
A separate NgModule that provides the necessary service providers
and directives for navigating through application views.
- 一个独立的 NgModule,用于提供所需的服务提供商,以及用来在应用视图之间进行导航的指令。
+ 一个独立的 NgModule,用于提供所需的服务提供者,以及用来在应用视图之间进行导航的指令。
@@ -1364,14 +1364,14 @@ In order to use the Router, you must first register the `RouterModule` from the
要使用路由器,必须先注册来自 `@angular/router` 包中的 `RouterModule`。
定义一个路由数组 `appRoutes` 并把它传给 `RouterModule.forRoot()` 方法。
-它会返回一个模块,其中包含配置好的 `Router` 服务提供商,以及路由库所需的其它提供商。
+它会返回一个模块,其中包含配置好的 `Router` 服务提供者,以及路由库所需的其它提供者。
一旦启动了应用,`Router` 就会根据当前的浏览器 URL 进行首次导航。
**Note:** The `RouterModule.forRoot` method is a pattern used to register application-wide providers. Read more about application-wide providers in the [Singleton services](guide/singleton-services#forRoot-router) guide.
- **注意:** `RouterModule.forRoot` 方法是用于注册全应用级提供商的编码模式。要详细了解全应用级提供商,参见[单例服务](guide/singleton-services#forRoot-router) 一章。
+ **注意:** `RouterModule.forRoot` 方法是用于注册全应用级提供者的编码模式。要详细了解全应用级提供者,参见[单例服务](guide/singleton-services#forRoot-router) 一章。
@@ -1849,7 +1849,7 @@ The **Routing Module** has several characteristics:
* Provides a well-known location for routing service providers including guards and resolvers.
- 为路由服务提供商(包括守卫和解析器等)提供一个共同的地方。
+ 为路由服务提供者(包括守卫和解析器等)提供一个共同的地方。
* Does **not** declare components.
@@ -2239,7 +2239,7 @@ In the `AppRoutingModule`, you used the static **`RouterModule.forRoot()`** meth
In a feature module you use the static **`forChild`** method.
这里有少量但是关键的不同点。
-在 `AppRoutingModule` 中,你使用了静态的 `RouterModule.`**`forRoot`**方法来注册路由和全应用级服务提供商。
+在 `AppRoutingModule` 中,你使用了静态的 `RouterModule.`**`forRoot`**方法来注册路由和全应用级服务提供者。
在特性模块中,你要改用**`forChild`**静态方法。
@@ -5929,7 +5929,7 @@ URLs with hashes. Here's a "hash URL" that routes to the *Crisis Center*.
The router supports both styles with two `LocationStrategy` providers:
-路由器通过两种 `LocationStrategy` 提供商来支持所有这些风格:
+路由器通过两种 `LocationStrategy` 提供者来支持所有这些风格:
1. `PathLocationStrategy`—the default "HTML5 pushState" style.
@@ -5951,7 +5951,7 @@ You can switch to the `HashLocationStrategy` with an override during the bootstr
Learn about providers and the bootstrap process in the
[Dependency Injection guide](guide/dependency-injection#bootstrap).
-要学习关于“提供商”和启动过程的更多知识,参见[依赖注入](guide/dependency-injection#bootstrap)一章。
+要学习关于“提供者”和启动过程的更多知识,参见[依赖注入](guide/dependency-injection#bootstrap)一章。
diff --git a/aio/content/guide/sharing-ngmodules.md b/aio/content/guide/sharing-ngmodules.md
index 37cad6a41d..a6acf33f7c 100644
--- a/aio/content/guide/sharing-ngmodules.md
+++ b/aio/content/guide/sharing-ngmodules.md
@@ -81,7 +81,7 @@ The most common way to get a hold of shared services is through Angular
To read about sharing services, see [Providers](guide/providers).
-要进一步了解共享服务,参见[服务提供商](guide/providers)。
+要进一步了解共享服务,参见[服务提供者](guide/providers)。
@@ -95,7 +95,7 @@ You may also be interested in the following:
* [Providers](guide/providers).
- [服务提供商](guide/providers)。
+ [服务提供者](guide/providers)。
* [Types of Feature Modules](guide/module-types).
diff --git a/aio/content/guide/singleton-services.md b/aio/content/guide/singleton-services.md
index d87abd5066..7ba0d28ac0 100644
--- a/aio/content/guide/singleton-services.md
+++ b/aio/content/guide/singleton-services.md
@@ -112,7 +112,7 @@ Use `forRoot()` to
separate providers from a module so you can import that module into the root module
with `providers` and child modules without `providers`.
-使用 `forRoot()` 来把提供商从该模块中分离出去,这样你就能在根模块中导入该模块时带上 `providers` ,并且在子模块中导入它时不带 `providers`。
+使用 `forRoot()` 来把提供者从该模块中分离出去,这样你就能在根模块中导入该模块时带上 `providers` ,并且在子模块中导入它时不带 `providers`。
1. Create a static method `forRoot()` on the module.
@@ -120,7 +120,7 @@ with `providers` and child modules without `providers`.
2. Place the providers into the `forRoot()` method.
- 把这些提供商放进 `forRoot()` 方法中。
+ 把这些提供者放进 `forRoot()` 方法中。
@@ -168,7 +168,7 @@ a simple object with the following properties:
* `providers`: the configured providers.
- `providers` - 配置好的服务提供商
+ `providers` - 配置好的服务提供者
In the live example
the root `AppModule` imports the `GreetingModule` and adds the
@@ -179,7 +179,7 @@ This sequence ensures that whatever you add explicitly to
the `AppModule` providers takes precedence over the providers
of imported modules.
-在这个 现场演练中,根模块 `AppModule` 导入了 `GreetingModule`,并把它的 `providers` 添加到了 `AppModule` 的服务提供商列表中。特别是,Angular 会把所有从其它模块导入的提供商追加到本模块的 `@NgModule.providers` 中列出的提供商之前。这种顺序可以确保你在 `AppModule` 的 `providers` 中显式列出的提供商,其优先级高于导入模块中给出的提供商。
+在这个 现场演练中,根模块 `AppModule` 导入了 `GreetingModule`,并把它的 `providers` 添加到了 `AppModule` 的服务提供者列表中。特别是,Angular 会把所有从其它模块导入的提供者追加到本模块的 `@NgModule.providers` 中列出的提供者之前。这种顺序可以确保你在 `AppModule` 的 `providers` 中显式列出的提供者,其优先级高于导入模块中给出的提供者。
The sample app imports `GreetingModule` and uses its `forRoot()` method one time, in `AppModule`. Registering it once like this prevents multiple instances.
@@ -255,7 +255,7 @@ The `@Optional()` decorator means not finding the service is OK.
The injector returns `null`, the `parentModule` parameter is null,
and the constructor concludes uneventfully.
-默认情况下,当注入器找不到想找的提供商时,会抛出一个错误。
+默认情况下,当注入器找不到想找的提供者时,会抛出一个错误。
但 `@Optional()` 装饰器表示找不到该服务也无所谓。
于是注入器会返回 `null`,`parentModule` 参数也就被赋成了空值,而构造函数没有任何异常。
diff --git a/aio/content/guide/styleguide.md b/aio/content/guide/styleguide.md
index 0b5b8d408c..178af2983c 100644
--- a/aio/content/guide/styleguide.md
+++ b/aio/content/guide/styleguide.md
@@ -2636,7 +2636,7 @@ that may need features from another common module; for example,
**Avoid** specifying app-wide singleton providers in a `SharedModule`. Intentional singletons are OK. Take care.
-**避免**在 `SharedModule` 中指定应用级的单例服务提供商。如果是刻意要得到多个服务单例也行,不过还是要小心。
+**避免**在 `SharedModule` 中指定应用级的单例服务提供者。如果是刻意要得到多个服务单例也行,不过还是要小心。