docs(API): 翻译完了各个生命周期钩子

This commit is contained in:
Zhicheng Wang 2018-09-04 12:32:48 +08:00
parent d1985fc7d1
commit 201976fd31
2 changed files with 78 additions and 4 deletions

View File

@ -52,7 +52,7 @@
[x] | core/TemplateRef | 0.38 [x] | core/TemplateRef | 0.38
[x] | forms/FormBuilder | 0.37 [x] | forms/FormBuilder | 0.37
[x] | common/http/HttpParams | 0.35 [x] | common/http/HttpParams | 0.35
[ ] | core/OnChanges | 0.35 [x] | core/OnChanges | 0.35
[ ] | forms/FormControlName | 0.34 [ ] | forms/FormControlName | 0.34
[x] | core/Output | 0.33 [x] | core/Output | 0.33
[ ] | common/http/HttpInterceptor | 0.30 [ ] | common/http/HttpInterceptor | 0.30

View File

@ -13,6 +13,8 @@ import {SimpleChange} from '../change_detection/change_detection_util';
* Defines an object that associates properties with * Defines an object that associates properties with
* instances of `SimpleChange`. * instances of `SimpleChange`.
* *
* `SimpleChange`
*
* @see `OnChanges` * @see `OnChanges`
* *
*/ */
@ -23,14 +25,21 @@ export interface SimpleChanges { [propName: string]: SimpleChange; }
* A lifecycle hook that is called when any data-bound property of a directive changes. * A lifecycle hook that is called when any data-bound property of a directive changes.
* Define an `ngOnChanges()` method to handle the changes. * Define an `ngOnChanges()` method to handle the changes.
* *
*
* `ngOnChanges()`
*
* @see `DoCheck` * @see `DoCheck`
* @see `OnInit` * @see `OnInit`
* @see [Lifecycle Hooks](guide/lifecycle-hooks#onchanges) guide * @see [Lifecycle Hooks](guide/lifecycle-hooks#onchanges) guide
* *
* [](guide/lifecycle-hooks#onchanges)
*
* @usageNotes * @usageNotes
* The following snippet shows how a component can implement this interface to * The following snippet shows how a component can implement this interface to
* define an on-changes handler for an input property. * define an on-changes handler for an input property.
* *
*
*
* {@example core/ts/metadata/lifecycle_hooks_spec.ts region='OnChanges'} * {@example core/ts/metadata/lifecycle_hooks_spec.ts region='OnChanges'}
* *
*/ */
@ -40,7 +49,12 @@ export interface OnChanges {
* default change detector has checked data-bound properties * default change detector has checked data-bound properties
* if at least one has changed, and before the view and content * if at least one has changed, and before the view and content
* children are checked. * children are checked.
*
*
*
* @param changes The changed properties. * @param changes The changed properties.
*
*
*/ */
ngOnChanges(changes: SimpleChanges): void; ngOnChanges(changes: SimpleChanges): void;
} }
@ -87,22 +101,34 @@ export interface OnInit {
* A lifecycle hook that invokes a custom change-detection function for a directive, * A lifecycle hook that invokes a custom change-detection function for a directive,
* in addition to the check performed by the default change-detector. * in addition to the check performed by the default change-detector.
* *
* 使
*
* The default change-detection algorithm looks for differences by comparing * The default change-detection algorithm looks for differences by comparing
* bound-property values by reference across change detection runs. You can use this * bound-property values by reference across change detection runs. You can use this
* hook to check for and respond to changes by some other means. * hook to check for and respond to changes by some other means.
* *
*
* 使
*
* When the default change detector detects changes, it invokes `ngOnChanges()` if supplied, * When the default change detector detects changes, it invokes `ngOnChanges()` if supplied,
* regardless of whether you perform additional change detection. * regardless of whether you perform additional change detection.
* Typically, you should not use both `DoCheck` and `OnChanges` to respond to * Typically, you should not use both `DoCheck` and `OnChanges` to respond to
* changes on the same input. * changes on the same input.
* *
* `ngOnChanges()`
* 使 `DoCheck` `OnChanges`
*
* @see `OnChanges` * @see `OnChanges`
* @see [Lifecycle Hooks](guide/lifecycle-hooks#onchanges) guide * @see [Lifecycle Hooks](guide/lifecycle-hooks#onchanges) guide
* *
* [](guide/lifecycle-hooks#onchanges)
*
* @usageNotes * @usageNotes
* The following snippet shows how a component can implement this interface * The following snippet shows how a component can implement this interface
* to invoke it own change-detection cycle. * to invoke it own change-detection cycle.
* *
*
*
* {@example core/ts/metadata/lifecycle_hooks_spec.ts region='DoCheck'} * {@example core/ts/metadata/lifecycle_hooks_spec.ts region='DoCheck'}
* *
*/ */
@ -113,6 +139,8 @@ export interface DoCheck {
* See `KeyValueDiffers` and `IterableDiffers` for implementing * See `KeyValueDiffers` and `IterableDiffers` for implementing
* custom change checking for collections. * custom change checking for collections.
* *
*
* `KeyValueDiffers` `IterableDiffers`
*/ */
ngDoCheck(): void; ngDoCheck(): void;
} }
@ -121,12 +149,20 @@ export interface DoCheck {
* A lifecycle hook that is called when a directive, pipe, or service is destroyed. * A lifecycle hook that is called when a directive, pipe, or service is destroyed.
* Use for any custom cleanup that needs to occur when the * Use for any custom cleanup that needs to occur when the
* instance is destroyed. * instance is destroyed.
*
*
*
*
* @see [Lifecycle Hooks](guide/lifecycle-hooks#onchanges) guide * @see [Lifecycle Hooks](guide/lifecycle-hooks#onchanges) guide
* *
* [](guide/lifecycle-hooks#onchanges)
*
* @usageNotes * @usageNotes
* The following snippet shows how a component can implement this interface * The following snippet shows how a component can implement this interface
* to define its own custom clean-up method. * to define its own custom clean-up method.
* *
*
*
* {@example core/ts/metadata/lifecycle_hooks_spec.ts region='OnDestroy'} * {@example core/ts/metadata/lifecycle_hooks_spec.ts region='OnDestroy'}
* *
*/ */
@ -134,6 +170,8 @@ export interface OnDestroy {
/** /**
* A callback method that performs custom clean-up, invoked immediately * A callback method that performs custom clean-up, invoked immediately
* after a directive, pipe, or service instance is destroyed. * after a directive, pipe, or service instance is destroyed.
*
*
*/ */
ngOnDestroy(): void; ngOnDestroy(): void;
} }
@ -144,14 +182,21 @@ export interface OnDestroy {
* all content of a directive. * all content of a directive.
* Define an `ngAfterContentInit()` method to handle any additional initialization tasks. * Define an `ngAfterContentInit()` method to handle any additional initialization tasks.
* *
* Angular
* `ngAfterContentInit()`
*
* @see `OnInit` * @see `OnInit`
* @see `AfterViewInit` * @see `AfterViewInit`
* @see [Lifecycle Hooks](guide/lifecycle-hooks#onchanges) guide * @see [Lifecycle Hooks](guide/lifecycle-hooks#onchanges) guide
* *
* [](guide/lifecycle-hooks#onchanges)
*
* @usageNotes * @usageNotes
* The following snippet shows how a component can implement this interface to * The following snippet shows how a component can implement this interface to
* define its own content initialization method. * define its own content initialization method.
* *
*
*
* {@example core/ts/metadata/lifecycle_hooks_spec.ts region='AfterContentInit'} * {@example core/ts/metadata/lifecycle_hooks_spec.ts region='AfterContentInit'}
* *
* *
@ -162,6 +207,10 @@ export interface AfterContentInit {
* Angular has completed initialization of all of the directive's * Angular has completed initialization of all of the directive's
* content. * content.
* It is invoked only once when the directive is instantiated. * It is invoked only once when the directive is instantiated.
*
* Angular
*
*
*/ */
ngAfterContentInit(): void; ngAfterContentInit(): void;
} }
@ -171,13 +220,19 @@ export interface AfterContentInit {
* A lifecycle hook that is called after the default change detector has * A lifecycle hook that is called after the default change detector has
* completed checking all content of a directive. * completed checking all content of a directive.
* *
*
*
* @see `AfterViewChecked` * @see `AfterViewChecked`
* @see [Lifecycle Hooks](guide/lifecycle-hooks#onchanges) guide * @see [Lifecycle Hooks](guide/lifecycle-hooks#onchanges) guide
* *
* [](guide/lifecycle-hooks#onchanges)
*
* @usageNotes * @usageNotes
* The following snippet shows how a component can implement this interface to * The following snippet shows how a component can implement this interface to
* define its own after-check functionality. * define its own after-check functionality.
* *
*
*
* {@example core/ts/metadata/lifecycle_hooks_spec.ts region='AfterContentChecked'} * {@example core/ts/metadata/lifecycle_hooks_spec.ts region='AfterContentChecked'}
* *
* *
@ -187,6 +242,8 @@ export interface AfterContentChecked {
* A callback method that is invoked immediately after the * A callback method that is invoked immediately after the
* default change detector has completed checking all of the directive's * default change detector has completed checking all of the directive's
* content. * content.
*
*
*/ */
ngAfterContentChecked(): void; ngAfterContentChecked(): void;
} }
@ -197,14 +254,21 @@ export interface AfterContentChecked {
* a component's view. * a component's view.
* Define an `ngAfterViewInit()` method to handle any additional initialization tasks. * Define an `ngAfterViewInit()` method to handle any additional initialization tasks.
* *
* Angular
* `ngAfterViewInit()`
*
* @see `OnInit` * @see `OnInit`
* @see `AfterContentInit` * @see `AfterContentInit`
* @see [Lifecycle Hooks](guide/lifecycle-hooks#onchanges) guide * @see [Lifecycle Hooks](guide/lifecycle-hooks#onchanges) guide
* *
* [](guide/lifecycle-hooks#onchanges)
*
* @usageNotes * @usageNotes
* The following snippet shows how a component can implement this interface to * The following snippet shows how a component can implement this interface to
* define its own view initialization method. * define its own view initialization method.
* *
*
*
* {@example core/ts/metadata/lifecycle_hooks_spec.ts region='AfterViewInit'} * {@example core/ts/metadata/lifecycle_hooks_spec.ts region='AfterViewInit'}
* *
* *
@ -215,6 +279,8 @@ export interface AfterViewInit {
* Angular has completed initialization of a component's view. * Angular has completed initialization of a component's view.
* It is invoked only once when the view is instantiated. * It is invoked only once when the view is instantiated.
* *
* Angular
*
*/ */
ngAfterViewInit(): void; ngAfterViewInit(): void;
} }
@ -224,13 +290,19 @@ export interface AfterViewInit {
* A lifecycle hook that is called after the default change detector has * A lifecycle hook that is called after the default change detector has
* completed checking a component's view for changes. * completed checking a component's view for changes.
* *
*
*
* @see `AfterContentChecked` * @see `AfterContentChecked`
* @see [Lifecycle Hooks](guide/lifecycle-hooks#onchanges) guide * @see [Lifecycle Hooks](guide/lifecycle-hooks#onchanges) guide
* *
* [](guide/lifecycle-hooks#onchanges)
*
* @usageNotes * @usageNotes
* The following snippet shows how a component can implement this interface to * The following snippet shows how a component can implement this interface to
* define its own after-check functionality. * define its own after-check functionality.
* *
*
*
* {@example core/ts/metadata/lifecycle_hooks_spec.ts region='AfterViewChecked'} * {@example core/ts/metadata/lifecycle_hooks_spec.ts region='AfterViewChecked'}
* *
*/ */
@ -239,6 +311,8 @@ export interface AfterViewChecked {
* A callback method that is invoked immediately after the * A callback method that is invoked immediately after the
* default change detector has completed one change-check cycle * default change detector has completed one change-check cycle
* for a component's view. * for a component's view.
*
*
*/ */
ngAfterViewChecked(): void; ngAfterViewChecked(): void;
} }