From 6c0606469d93ce1586d42979b547797793c70c42 Mon Sep 17 00:00:00 2001 From: rexebin Date: Sat, 26 Nov 2016 17:11:47 +0000 Subject: [PATCH] review di. --- .../ts/latest/guide/dependency-injection.jade | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/public/docs/ts/latest/guide/dependency-injection.jade b/public/docs/ts/latest/guide/dependency-injection.jade index 794529f2f8..2bbb6fe358 100644 --- a/public/docs/ts/latest/guide/dependency-injection.jade +++ b/public/docs/ts/latest/guide/dependency-injection.jade @@ -159,7 +159,7 @@ block ctor-syntax We also leveraged TypeScript's constructor syntax for declaring parameters and properties simultaneously. - 再次借助TypeScript的构造器语法来同时定义参数和属性。 + 再次借助 TypeScript 的构造器语法来同时定义参数和属性。 :marked Now we create a car by passing the engine and tires to the constructor. @@ -205,7 +205,7 @@ block ctor-syntax during each test: `Car`类非常容易测试,因为现在我们对它的依赖有了完全的控制权。 - 在每个测试期间,我们可以往构造函数中传入mock对象,做想让它们做的事: + 在每个测试期间,我们可以往构造函数中传入 mock 对象,做想让它们做的事: - var stylePattern = { otl: /(new Car.*$)/gm }; +makeExample('dependency-injection/ts/app/car/car-creations.ts', 'car-ctor-instantiation-with-mocks', '', stylePattern)(format=".") @@ -415,7 +415,7 @@ block ctor-syntax that create the services our application requires. We'll explain what [providers](#providers) are later in this chapter. - 我们必须通过注册**提供商 (provider)**来配置注入器,这些提供商为应用创建所需服务。 + 我们必须通过注册**提供商 (provider)** 来配置注入器,这些提供商为应用创建所需服务。 在本章的稍后部分会解释什么是[提供商](#providers)。 We can either register a provider within an [NgModule](ngmodule.html) or in application components @@ -519,7 +519,7 @@ block ctor-syntax Angular injector to inject an instance of `HeroService` whenever it creates a new `HeroListComponent`. - 构造函数参数类型、`@Component`装饰器和父级的`providers`信息合起来告诉Angular的注入器, + 构造函数参数类型、`@Component`装饰器和父级的`providers`信息合起来告诉 Angular 的注入器, 任何新建`HeroListComponent`的时候,注入一个`HeroService`的实例。 #di-metadata @@ -626,7 +626,7 @@ block ctor-syntax //- FIXME refer to Dart API when that page becomes available. - var injUrl = '../api/core/index/Injectable-decorator.html'; h3#injectable Why @Injectable()? -h3#injectable 为什么要用@Injectable()? +h3#injectable 为什么要用 @Injectable()? :marked **@Injectable()** marks a class as available to an injector for instantiation. Generally speaking, an injector will report an @@ -661,7 +661,7 @@ block injectable-not-always-needed-in-ts ul(style="font-size:inherit") li p Future proofing: No need to remember @Injectable() when we add a dependency later. - p 面向未来: 没有必要记得在后来添加依赖的时候添加@Injectable()。 + p 面向未来: 没有必要记得在后来添加依赖的时候添加 @Injectable()。 li p Consistency: All services follow the same rules, and we don't have to wonder why #{_a} #{_decorator} is missing. p 一致性:所有的服务都遵循同样的规则,不需要考虑为什么某个地方少了一个。 @@ -681,7 +681,8 @@ block injectable-not-always-needed-in-ts identify a class as a target for instantiation by an injector. 我们**可以**添加它。但是没有必要,因为`HerosComponent`已经有`@Component`装饰器了, - `@Component`(和随后将会学到的`@Directive`和`@Pipe`一样)是 Injectable 的子类型。实际上,正是这些`Injectable`装饰器是把一个类标识为注入器实例化的目标。 + `@Component`(和随后将会学到的`@Directive`和`@Pipe`一样)是 Injectable 的子类型。 + 实际上,正是这些`Injectable`装饰器是把一个类标识为注入器实例化的目标。 +ifDocsFor('ts') .l-sub-section