Skip to content

Commit 7a49fab

Browse files
author
Zhicheng WANG
committed
fix: 把提供商批量替换为提供者
1 parent c180073 commit 7a49fab

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+328
-328
lines changed

aio/content/guide/aot-metadata-errors.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ export class MyComponent {}
110110

111111
The compiler generates the component factory, which includes the `useValue` provider code, in a separate module. _That_ factory module can't reach back to _this_ source module to access the local (non-exported) `foo` variable.
112112

113-
编译器会在单独的模块中生成这个 `userValue` 提供商的代码*那个*工厂模块不能访问*这个*源码模块,无法访问这个(未导出的)`foo` 变量。
113+
编译器会在单独的模块中生成这个 `userValue` 提供者的代码*那个*工厂模块不能访问*这个*源码模块,无法访问这个(未导出的)`foo` 变量。
114114

115115
You could fix the problem by initializing `foo`.
116116

@@ -124,7 +124,7 @@ let foo = 42; // initialized
124124

125125
The compiler will [fold](guide/aot-compiler#code-folding) the expression into the provider as if you had written this.
126126

127-
编译器会将表达式[折叠](guide/aot-compiler#code-folding)到提供商中,就像你自己写的一样。
127+
编译器会将表达式[折叠](guide/aot-compiler#code-folding)到提供者中,就像你自己写的一样。
128128

129129

130130
```ts
@@ -346,7 +346,7 @@ export abstract class MyStrategy { }
346346

347347
For example, you may have set a providers `useFactory` property to a locally defined function that you neglected to export.
348348

349-
比如,你可能已经把某个服务提供商的 `useFactory` 属性设置成了一个局部定义但忘了导出的函数。
349+
比如,你可能已经把某个服务提供者的 `useFactory` 属性设置成了一个局部定义但忘了导出的函数。
350350

351351
```ts
352352

@@ -401,7 +401,7 @@ _Function calls are not supported. Consider replacing the function or lambda wit
401401
The compiler does not currently support [function expressions or lambda functions](guide/aot-compiler#function-expression).
402402
For example, you cannot set a provider's `useFactory` to an anonymous function or arrow function like this.
403403

404-
编译器当前不支持[函数表达式或 lambda 函数](guide/aot-compiler#function-expression) 。例如,您不能将提供商的 `useFactory` 设置为这样的匿名函数或箭头函数。
404+
编译器当前不支持[函数表达式或 lambda 函数](guide/aot-compiler#function-expression) 。例如,您不能将提供者的 `useFactory` 设置为这样的匿名函数或箭头函数。
405405

406406

407407
```ts
@@ -418,7 +418,7 @@ For example, you cannot set a provider's `useFactory` to an anonymous function o
418418

419419
You also get this error if you call a function or method in a provider's `useValue`.
420420

421-
如果你在某个提供商的 `useValue` 中调用函数或方法,也会导致这个错误。
421+
如果你在某个提供者的 `useValue` 中调用函数或方法,也会导致这个错误。
422422

423423
```ts
424424

@@ -435,7 +435,7 @@ import { calculateValue } from './utilities';
435435

436436
To correct this error, export a function from the module and refer to the function in a `useFactory` provider instead.
437437

438-
要改正这个问题,就要从模块中导出这个函数,并改成在服务提供商的 `useFactory` 中引用该函数。
438+
要改正这个问题,就要从模块中导出这个函数,并改成在服务提供者的 `useFactory` 中引用该函数。
439439

440440
```ts
441441

@@ -582,7 +582,7 @@ you can finesse the problem in four steps:
582582

583583
1. Add a `useFactory` provider with that factory function.
584584

585-
使用该工厂函数添加一个 `useFactory` 提供商
585+
使用该工厂函数添加一个 `useFactory` 提供者
586586

587587
1. Use `@Inject` to inject the instance.
588588

aio/content/guide/architecture-components.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ Angular inserts an instance of the `HeroListComponent` view between those tags.
8787

8888
* `providers`: An array of [providers](guide/glossary#provider) for services that the component requires. In the example, this tells Angular how to provide the `HeroService` instance that the component's constructor uses to get the list of heroes to display.
8989

90-
`providers`:当前组件所需的服务[提供商](guide/glossary#provider)的一个数组。在这个例子中,它告诉 Angular 该如何提供一个 `HeroService` 实例,以获取要显示的英雄列表。
90+
`providers`:当前组件所需的服务[提供者](guide/glossary#provider)的一个数组。在这个例子中,它告诉 Angular 该如何提供一个 `HeroService` 实例,以获取要显示的英雄列表。
9191

9292
## Templates and views
9393

aio/content/guide/architecture-modules.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ NgModules are containers for a cohesive block of code dedicated to an applicatio
77

88
Angular 应用是模块化的,它拥有自己的模块化系统,称作 *NgModule*
99
一个 NgModule 就是一个容器,用于存放一些内聚的代码块,这些代码块专注于某个应用领域、某个工作流或一组紧密相关的功能。
10-
它可以包含一些组件、服务提供商或其它代码文件,其作用域由包含它们的 NgModule 定义。
10+
它可以包含一些组件、服务提供者或其它代码文件,其作用域由包含它们的 NgModule 定义。
1111
它还可以导入一些由其它模块中导出的功能,并导出一些指定的功能供其它 NgModule 使用。
1212

1313
Every Angular app has at least one NgModule class, [the *root module*](guide/bootstrapping), which is conventionally named `AppModule` and resides in a file named `app.module.ts`. You launch your app by *bootstrapping* the root NgModule.
@@ -41,7 +41,7 @@ NgModule 是一个带有 `@NgModule()` 装饰器的类。`@NgModule()` 装饰器
4141
* `providers`: Creators of [services](guide/architecture-services) that this NgModule contributes to the global collection of services; they become accessible in all parts of the app. (You can also specify providers at the component level, which is often preferred.)
4242

4343
`providers` —— 本模块向全局服务中贡献的那些[服务](guide/architecture-services)的创建器。
44-
这些服务能被本应用中的任何部分使用。(你也可以在组件级别指定服务提供商,这通常是首选方式。)
44+
这些服务能被本应用中的任何部分使用。(你也可以在组件级别指定服务提供者,这通常是首选方式。)
4545

4646
* `bootstrap`: The main application view, called the *root component*, which hosts all other app views. Only the *root NgModule* should set the `bootstrap` property.
4747

aio/content/guide/architecture-services.md

+11-11
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ You can also make your app more adaptable by injecting different providers of th
3131
as appropriate in different circumstances.
3232

3333
组件应该把诸如从服务器获取数据、验证用户输入或直接往控制台中写日志等工作委托给各种服务。通过把各种处理任务定义到可注入的服务类中,你可以让它被任何组件使用。
34-
通过在不同的环境中注入同一种服务的不同提供商,你还可以让你的应用更具适应性。
34+
通过在不同的环境中注入同一种服务的不同提供者,你还可以让你的应用更具适应性。
3535

3636
Angular doesn't *enforce* these principles. Angular does help you *follow* these principles
3737
by making it easy to factor your application logic into services and make those services
@@ -83,14 +83,14 @@ Similarly, use the `@Injectable()` decorator to indicate that a component or oth
8383

8484
* A *provider* is an object that tells an injector how to obtain or create a dependency.
8585

86-
*提供商*是一个对象,用来告诉注入器应该如何获取或创建依赖。
86+
*提供者*是一个对象,用来告诉注入器应该如何获取或创建依赖。
8787

8888
For any dependency that you need in your app, you must register a provider with the app's injector,
8989
so that the injector can use the provider to create new instances.
9090
For a service, the provider is typically the service class itself.
9191

92-
你的应用中所需的任何依赖,都必须使用该应用的注入器来注册一个提供商,以便注入器可以使用这个提供商来创建新实例
93-
对于服务,该提供商通常就是服务类本身
92+
你的应用中所需的任何依赖,都必须使用该应用的注入器来注册一个提供者,以便注入器可以使用这个提供者来创建新实例
93+
对于服务,该提供者通常就是服务类本身
9494

9595
<div class="alert is-helpful">
9696

@@ -109,7 +109,7 @@ When Angular creates a new instance of a component class, it determines which se
109109

110110
When Angular discovers that a component depends on a service, it first checks if the injector has any existing instances of that service. If a requested service instance doesn't yet exist, the injector makes one using the registered provider, and adds it to the injector before returning the service to Angular.
111111

112-
当 Angular 发现某个组件依赖某个服务时,它会首先检查是否该注入器中已经有了那个服务的任何现有实例。如果所请求的服务尚不存在,注入器就会使用以前注册的服务提供商来制作一个,并把它加入注入器中,然后把该服务返回给 Angular。
112+
当 Angular 发现某个组件依赖某个服务时,它会首先检查是否该注入器中已经有了那个服务的任何现有实例。如果所请求的服务尚不存在,注入器就会使用以前注册的服务提供者来制作一个,并把它加入注入器中,然后把该服务返回给 Angular。
113113

114114
When all requested services have been resolved and returned, Angular can call the component's constructor with those services as arguments.
115115

@@ -133,11 +133,11 @@ or you can register providers with specific modules or components.
133133
You register providers in the metadata of the service (in the `@Injectable()` decorator),
134134
or in the `@NgModule()` or `@Component()` metadata
135135

136-
对于要用到的任何服务,你必须至少注册一个*提供商*。服务可以在自己的元数据中把自己注册为提供商,这样可以让自己随处可用。或者,你也可以为特定的模块或组件注册提供商。要注册提供商,就要在服务的 `@Injectable()` 装饰器中提供它的元数据,或者在`@NgModule()``@Component()` 的元数据中。
136+
对于要用到的任何服务,你必须至少注册一个*提供者*。服务可以在自己的元数据中把自己注册为提供者,这样可以让自己随处可用。或者,你也可以为特定的模块或组件注册提供者。要注册提供者,就要在服务的 `@Injectable()` 装饰器中提供它的元数据,或者在`@NgModule()``@Component()` 的元数据中。
137137

138138
* By default, the Angular CLI command [`ng generate service`](cli/generate) registers a provider with the root injector for your service by including provider metadata in the `@Injectable()` decorator. The tutorial uses this method to register the provider of HeroService class definition.
139139

140-
默认情况下,Angular CLI 的 [`ng generate service`](cli/generate) 命令会在 `@Injectable()` 装饰器中提供元数据来把它注册到根注入器中。本教程就用这种方法注册了 HeroService 的提供商
140+
默认情况下,Angular CLI 的 [`ng generate service`](cli/generate) 命令会在 `@Injectable()` 装饰器中提供元数据来把它注册到根注入器中。本教程就用这种方法注册了 HeroService 的提供者
141141

142142
```
143143
@Injectable({
@@ -150,11 +150,11 @@ or in the `@NgModule()` or `@Component()` metadata
150150
Registering the provider in the `@Injectable()` metadata also allows Angular to optimize an app
151151
by removing the service from the compiled app if it isn't used.
152152

153-
当你在根一级提供服务时,Angular 会为 HeroService 创建一个单一的共享实例,并且把它注入到任何想要它的类中。这种在 `@Injectable` 元数据中注册提供商的方式还让 Angular 能够通过移除那些从未被用过的服务来优化大小。
153+
当你在根一级提供服务时,Angular 会为 HeroService 创建一个单一的共享实例,并且把它注入到任何想要它的类中。这种在 `@Injectable` 元数据中注册提供者的方式还让 Angular 能够通过移除那些从未被用过的服务来优化大小。
154154

155155
* When you register a provider with a [specific NgModule](guide/architecture-modules), the same instance of a service is available to all components in that NgModule. To register at this level, use the `providers` property of the `@NgModule()` decorator,
156156

157-
当你使用[特定的 NgModule](guide/architecture-modules) 注册提供商时,该服务的同一个实例将会对该 NgModule 中的所有组件可用。要想在这一层注册,请用 `@NgModule()` 装饰器中的 `providers` 属性:
157+
当你使用[特定的 NgModule](guide/architecture-modules) 注册提供者时,该服务的同一个实例将会对该 NgModule 中的所有组件可用。要想在这一层注册,请用 `@NgModule()` 装饰器中的 `providers` 属性:
158158

159159
```
160160
@NgModule({
@@ -170,8 +170,8 @@ or in the `@NgModule()` or `@Component()` metadata
170170
service with each new instance of that component.
171171
At the component level, register a service provider in the `providers` property of the `@Component()` metadata.
172172

173-
当你在组件级注册提供商时,你会为该组件的每一个新实例提供该服务的一个新实例。
174-
要在组件级注册,就要在 `@Component()` 元数据的 `providers` 属性中注册服务提供商
173+
当你在组件级注册提供者时,你会为该组件的每一个新实例提供该服务的一个新实例。
174+
要在组件级注册,就要在 `@Component()` 元数据的 `providers` 属性中注册服务提供者
175175

176176
<code-example path="architecture/src/app/hero-list.component.ts" header="src/app/hero-list.component.ts (component providers)" region="providers"></code-example>
177177

aio/content/guide/architecture.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ NgModule 会把相关的代码收集到一些功能集中。Angular 应用就是
2323

2424
* Components use *services*, which provide specific functionality not directly related to views. Service providers can be *injected* into components as *dependencies*, making your code modular, reusable, and efficient.
2525

26-
组件使用*服务*。服务会提供那些与视图不直接相关的功能。服务提供商可以作为*依赖**注入*到组件中,
26+
组件使用*服务*。服务会提供那些与视图不直接相关的功能。服务提供者可以作为*依赖**注入*到组件中,
2727
这能让你的代码更加模块化、更加可复用、更加高效。
2828

2929
Both components and services are simply classes, with *decorators* that mark their type and provide metadata that tells Angular how to use them.

aio/content/guide/bootstrapping.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ The `@NgModule` decorator identifies `AppModule` as an `NgModule` class.
7777

7878
* **_providers_**&mdash;the service providers.
7979

80-
**_providers_** —— 各种服务提供商
80+
**_providers_** —— 各种服务提供者
8181

8282
* **_bootstrap_**&mdash;the _root_ component that Angular creates and inserts
8383
into the `index.html` host web page.
@@ -235,7 +235,7 @@ them when using feature modules and lazy loading. For more information, see
235235
[Providers](guide/providers).
236236

237237
`providers` 数组中列出了该应用所需的服务。当直接把服务列在这里时,它们是全应用范围的。
238-
当你使用特性模块和惰性加载时,它们是范围化的。要了解更多,参见[服务提供商](guide/providers)
238+
当你使用特性模块和惰性加载时,它们是范围化的。要了解更多,参见[服务提供者](guide/providers)
239239

240240
## The `bootstrap` array
241241

aio/content/guide/cheatsheet.md

+8-8
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555

5656
<p>Defines a module that contains components, directives, pipes, and providers.</p>
5757

58-
<p>定义一个模块,其中可以包含组件、指令、管道和服务提供商。</p>
58+
<p>定义一个模块,其中可以包含组件、指令、管道和服务提供者。</p>
5959

6060
</td>
6161

@@ -120,7 +120,7 @@ is available to <code>declarations</code> of this module.</p>
120120

121121
<p>List of dependency injection providers visible both to the contents of this module and to importers of this module.</p>
122122

123-
<p>依赖注入提供商的列表,本模块以及本模块导入的所有模块中的内容都可以看见它们。</p>
123+
<p>依赖注入提供者的列表,本模块以及本模块导入的所有模块中的内容都可以看见它们。</p>
124124

125125
</td>
126126

@@ -617,7 +617,7 @@ is available to <code>declarations</code> of this module.</p>
617617

618618
<p>Declares that a class can be provided and injected by other classes. Without this decorator, the compiler won't generate enough metadata to allow the class to be created properly when it's injected somewhere.</p>
619619

620-
<p>声明某个类可以注册为提供商,并能被另一个类注入。如果没有该装饰器,编译器就不会生成足够的元数据,当它被注入到别处时,就无法正常创建该类。</p>
620+
<p>声明某个类可以注册为提供者,并能被另一个类注入。如果没有该装饰器,编译器就不会生成足够的元数据,当它被注入到别处时,就无法正常创建该类。</p>
621621
</td>
622622

623623
</tr>
@@ -675,7 +675,7 @@ is available to <code>declarations</code> of this module.</p>
675675

676676
<p>List of dependency injection providers for this directive and its children.</p>
677677

678-
<p>该指令及其子指令的依赖注入提供商列表。</p>
678+
<p>该指令及其子指令的依赖注入提供者列表。</p>
679679

680680
</td>
681681

@@ -733,7 +733,7 @@ so the <code>@Directive</code> configuration applies to components as well</p>
733733

734734
<p>List of dependency injection providers scoped to this component's view.</p>
735735

736-
<p>依赖注入提供商列表,但它们的范围被限定为当前组件的视图。</p>
736+
<p>依赖注入提供者列表,但它们的范围被限定为当前组件的视图。</p>
737737

738738
</td>
739739

@@ -1119,7 +1119,7 @@ so the <code>@Directive</code> configuration applies to components as well</p>
11191119

11201120
<p>Sets or overrides the provider for <code>MyService</code> to the <code>MyMockService</code> class.</p>
11211121

1122-
<p>把 <code>MyService</code> 的服务提供商设置或改写为 <code>MyMockService</code> 类。</p>
1122+
<p>把 <code>MyService</code> 的服务提供者设置或改写为 <code>MyMockService</code> 类。</p>
11231123

11241124
</td>
11251125

@@ -1135,7 +1135,7 @@ so the <code>@Directive</code> configuration applies to components as well</p>
11351135

11361136
<p>Sets or overrides the provider for <code>MyService</code> to the <code>myFactory</code> factory function.</p>
11371137

1138-
<p>把 <code>MyService</code> 的服务提供商设置或改写为 <code>myFactory</code> 工厂函数。</p>
1138+
<p>把 <code>MyService</code> 的服务提供者设置或改写为 <code>myFactory</code> 工厂函数。</p>
11391139

11401140
</td>
11411141

@@ -1151,7 +1151,7 @@ so the <code>@Directive</code> configuration applies to components as well</p>
11511151

11521152
<p>Sets or overrides the provider for <code>MyValue</code> to the value <code>41</code>.</p>
11531153

1154-
<p>把 <code>MyValue</code> 的服务提供商改写为一个特定的值 <code>41</code> 。</p>
1154+
<p>把 <code>MyValue</code> 的服务提供者改写为一个特定的值 <code>41</code> 。</p>
11551155

11561156
</td>
11571157

0 commit comments

Comments
 (0)