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] | forms/FormBuilder | 0.37
[x] | common/http/HttpParams | 0.35
[ ] | core/OnChanges | 0.35
[x] | core/OnChanges | 0.35
[ ] | forms/FormControlName | 0.34
[x] | core/Output | 0.33
[ ] | 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
* instances of `SimpleChange`.
*
* `SimpleChange`
*
* @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.
* Define an `ngOnChanges()` method to handle the changes.
*
*
* `ngOnChanges()`
*
* @see `DoCheck`
* @see `OnInit`
* @see [Lifecycle Hooks](guide/lifecycle-hooks#onchanges) guide
*
* [](guide/lifecycle-hooks#onchanges)
*
* @usageNotes
* The following snippet shows how a component can implement this interface to
* define an on-changes handler for an input property.
*
*
*
* {@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
* if at least one has changed, and before the view and content
* children are checked.
*
*
*
* @param changes The changed properties.
*
*
*/
ngOnChanges(changes: SimpleChanges): void;
}
@ -86,23 +100,35 @@ export interface OnInit {
/**
* A lifecycle hook that invokes a custom change-detection function for a directive,
* in addition to the check performed by the default change-detector.
*
* 使
*
* The default change-detection algorithm looks for differences by comparing
* 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.
*
*
* 使
*
* When the default change detector detects changes, it invokes `ngOnChanges()` if supplied,
* regardless of whether you perform additional change detection.
* 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 [Lifecycle Hooks](guide/lifecycle-hooks#onchanges) guide
*
* [](guide/lifecycle-hooks#onchanges)
*
* @usageNotes
* The following snippet shows how a component can implement this interface
* to invoke it own change-detection cycle.
*
*
*
* {@example core/ts/metadata/lifecycle_hooks_spec.ts region='DoCheck'}
*
*/
@ -113,6 +139,8 @@ export interface DoCheck {
* See `KeyValueDiffers` and `IterableDiffers` for implementing
* custom change checking for collections.
*
*
* `KeyValueDiffers` `IterableDiffers`
*/
ngDoCheck(): void;
}
@ -121,12 +149,20 @@ export interface DoCheck {
* 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
* instance is destroyed.
*
*
*
*
* @see [Lifecycle Hooks](guide/lifecycle-hooks#onchanges) guide
*
* [](guide/lifecycle-hooks#onchanges)
*
* @usageNotes
* The following snippet shows how a component can implement this interface
* to define its own custom clean-up method.
*
*
*
*
* {@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
* after a directive, pipe, or service instance is destroyed.
*
*
*/
ngOnDestroy(): void;
}
@ -144,14 +182,21 @@ export interface OnDestroy {
* all content of a directive.
* Define an `ngAfterContentInit()` method to handle any additional initialization tasks.
*
* Angular
* `ngAfterContentInit()`
*
* @see `OnInit`
* @see `AfterViewInit`
* @see [Lifecycle Hooks](guide/lifecycle-hooks#onchanges) guide
*
* [](guide/lifecycle-hooks#onchanges)
*
* @usageNotes
* The following snippet shows how a component can implement this interface to
* define its own content initialization method.
*
*
*
* {@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
* content.
* It is invoked only once when the directive is instantiated.
*
* Angular
*
*
*/
ngAfterContentInit(): void;
}
@ -171,13 +220,19 @@ export interface AfterContentInit {
* A lifecycle hook that is called after the default change detector has
* completed checking all content of a directive.
*
*
*
* @see `AfterViewChecked`
* @see [Lifecycle Hooks](guide/lifecycle-hooks#onchanges) guide
*
* [](guide/lifecycle-hooks#onchanges)
*
* @usageNotes
* The following snippet shows how a component can implement this interface to
* define its own after-check functionality.
*
*
*
* {@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
* default change detector has completed checking all of the directive's
* content.
*
*
*/
ngAfterContentChecked(): void;
}
@ -197,14 +254,21 @@ export interface AfterContentChecked {
* a component's view.
* Define an `ngAfterViewInit()` method to handle any additional initialization tasks.
*
* Angular
* `ngAfterViewInit()`
*
* @see `OnInit`
* @see `AfterContentInit`
* @see [Lifecycle Hooks](guide/lifecycle-hooks#onchanges) guide
*
* [](guide/lifecycle-hooks#onchanges)
*
* @usageNotes
* The following snippet shows how a component can implement this interface to
* define its own view initialization method.
*
*
*
* {@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.
* It is invoked only once when the view is instantiated.
*
* Angular
*
*/
ngAfterViewInit(): void;
}
@ -224,13 +290,19 @@ export interface AfterViewInit {
* A lifecycle hook that is called after the default change detector has
* completed checking a component's view for changes.
*
*
*
* @see `AfterContentChecked`
* @see [Lifecycle Hooks](guide/lifecycle-hooks#onchanges) guide
*
* [](guide/lifecycle-hooks#onchanges)
*
* @usageNotes
* The following snippet shows how a component can implement this interface to
* define its own after-check functionality.
*
*
*
* {@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
* default change detector has completed one change-check cycle
* for a component's view.
*
*
*/
ngAfterViewChecked(): void;
}