From 2408128394cc7bc554005cbf0c7d2614aa42feef Mon Sep 17 00:00:00 2001 From: Zhicheng Wang Date: Fri, 31 Aug 2018 18:31:27 +0800 Subject: [PATCH] =?UTF-8?q?docs(API):=20=E7=BF=BB=E8=AF=91=20injectable?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- aio/content/translations/cn/api-plan.md | 2 +- packages/core/src/di/injectable.ts | 20 ++++++++++++++++++++ packages/core/src/metadata/directives.ts | 10 +++++----- 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/aio/content/translations/cn/api-plan.md b/aio/content/translations/cn/api-plan.md index 5f79a2432e..3a7098260c 100644 --- a/aio/content/translations/cn/api-plan.md +++ b/aio/content/translations/cn/api-plan.md @@ -17,7 +17,7 @@ [ ] |forms/FormsModule | 3,381 | 1.05 [x] |core/Input | 3,354 | 1.04 [x] |core/EventEmitter | 3,202 | 0.99 -[ ] |core/Injectable | 3,177 | 0.99 +[x] |core/Injectable | 3,177 | 0.99 [ ] |forms/FormGroup | 3,096 | 0.96 [ ] |forms/FormControl | 3,034 | 0.94 [ ] |router/ActivatedRoute | 2,993 | 0.93 diff --git a/packages/core/src/di/injectable.ts b/packages/core/src/di/injectable.ts index d1dacf1033..8b162d4e03 100644 --- a/packages/core/src/di/injectable.ts +++ b/packages/core/src/di/injectable.ts @@ -23,6 +23,8 @@ const USE_VALUE = getClosureSafeProperty( /** * Injectable providers used in `@Injectable` decorator. * + * `@Injectable` 装饰器中使用的可注入对象提供商。 + * * @experimental */ export type InjectableProvider = ValueSansProvider | ExistingSansProvider | @@ -30,21 +32,31 @@ export type InjectableProvider = ValueSansProvider | ExistingSansProvider | /** * Type of the Injectable decorator / constructor function. + * + * Injectable 装饰器的类型和构造函数 */ export interface InjectableDecorator { /** * A marker metadata that marks a class as available to `Injector` for creation. * + * 标记性元数据,表示一个类可以由 `Injector` 进行创建。 + * * For more details, see the ["Dependency Injection Guide"](guide/dependency-injection). * + * 欲知详情,参见["依赖注入"](guide/dependency-injection)。 + * * @usageNotes * ### Example * + * ### 范例 + * * {@example core/di/ts/metadata_spec.ts region='Injectable'} * * `Injector` will throw an error when trying to instantiate a class that * does not have `@Injectable` marker, as shown in the example below. * + * `Injector`在试图实例化一个不带 `@Injectable` 标记的类时,就会抛出一个错误,如下面的例子所示。 + * * {@example core/di/ts/metadata_spec.ts region='InjectableThrows'} * */ @@ -57,6 +69,8 @@ export interface InjectableDecorator { /** * Type of the Injectable metadata. * + * Injectable 元数据的类型。 + * * @experimental */ export interface Injectable { providedIn?: Type|'root'|null; } @@ -101,6 +115,8 @@ export function convertInjectableProviderToFactory( /** * Supports @Injectable() in JIT mode for Render2. + * + * 在 JIT 模式下为 Render2 提供 `@Injectable()` 支持。 */ function preR3InjectableCompile( injectableType: InjectableType, @@ -116,6 +132,8 @@ function preR3InjectableCompile( /** * Injectable decorator and metadata. * +* Injectable 的装饰器和元数据。 +* * @Annotation */ export const Injectable: InjectableDecorator = makeDecorator( @@ -126,6 +144,8 @@ export const Injectable: InjectableDecorator = makeDecorator( /** * Type representing injectable service. * + * 表示可注入服务的类型。 + * * @experimental */ export interface InjectableType extends Type { ngInjectableDef: InjectableDef; } diff --git a/packages/core/src/metadata/directives.ts b/packages/core/src/metadata/directives.ts index 76ba069aec..5de1486c73 100644 --- a/packages/core/src/metadata/directives.ts +++ b/packages/core/src/metadata/directives.ts @@ -17,7 +17,7 @@ import {ViewEncapsulation} from './view'; /** * Type of the Directive decorator / constructor function. * - * 指令装饰器、构造函数的类型。 + * 指令装饰器的类型和构造函数。 */ export interface DirectiveDecorator { /** @@ -908,7 +908,7 @@ export const Component: ComponentDecorator = makeDecorator( /** * Type of the Pipe decorator / constructor function. * - * Pipe 装饰器、构造函数的类型 + * Pipe 装饰器的类型和构造函数。 */ export interface PipeDecorator { /** @@ -1073,7 +1073,7 @@ export const Input: InputDecorator = /** * Type of the Output decorator / constructor function. * - * `Output` 装饰器、构造函数的类型。 + * `Output` 装饰器的类型和构造函数。 */ export interface OutputDecorator { /** @@ -1120,7 +1120,7 @@ export const Output: OutputDecorator = /** * Type of the HostBinding decorator / constructor function. * - * HostBinding 装饰器、构造函数的类型。 + * HostBinding 装饰器的类型和构造函数。 * */ export interface HostBindingDecorator { @@ -1180,7 +1180,7 @@ export const HostBinding: HostBindingDecorator = /** * Type of the HostListener decorator / constructor function. * - * HostListener 装饰器、构造函数的类型 + * HostListener 装饰器的类型和构造函数。 */ export interface HostListenerDecorator { (eventName: string, args?: string[]): any;