docs(LifecycleHooks): correct ngDoCheck description (#8807)
The current behavior is for ngDoCheck to supplement, not override, the default change detector. OnChanges will still be called when DoCheck is implemented (fixes #7307).
This commit is contained in:
parent
fa2ce8100b
commit
3a62023260
|
@ -130,22 +130,19 @@ export abstract class OnChanges { abstract ngOnChanges(changes: SimpleChanges);
|
||||||
export abstract class OnInit { abstract ngOnInit(); }
|
export abstract class OnInit { abstract ngOnInit(); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implement this interface to override the default change detection algorithm for your directive.
|
* Implement this interface to supplement the default change detection algorithm in your directive.
|
||||||
*
|
*
|
||||||
* `ngDoCheck` gets called to check the changes in the directives instead of the default algorithm.
|
* `ngDoCheck` gets called to check the changes in the directives in addition to the default algorithm.
|
||||||
*
|
*
|
||||||
* The default change detection algorithm looks for differences by comparing bound-property values
|
* The default change detection algorithm looks for differences by comparing bound-property values
|
||||||
* by reference across change detection runs. When `DoCheck` is implemented, the default algorithm
|
* by reference across change detection runs.
|
||||||
* is disabled and `ngDoCheck` is responsible for checking for changes.
|
|
||||||
*
|
*
|
||||||
* Implementing this interface allows improving performance by using insights about the component,
|
* Note that a directive typically should not use both `DoCheck` and {@link OnChanges} to respond to
|
||||||
* its implementation and data types of its properties.
|
* changes on the same input. `ngOnChanges` will continue to be called when the default change detector
|
||||||
|
* detects changes, so it is usually unnecessary to respond to changes on the same input in both hooks.
|
||||||
|
* Reaction to the changes have to be handled from within the `ngDoCheck` callback.
|
||||||
*
|
*
|
||||||
* Note that a directive should not implement both `DoCheck` and {@link OnChanges} at the same time.
|
* You can use {@link KeyValueDiffers} and {@link IterableDiffers} to help add your custom check mechanisms.
|
||||||
* `ngOnChanges` would not be called when a directive implements `DoCheck`. Reaction to the changes
|
|
||||||
* have to be handled from within the `ngDoCheck` callback.
|
|
||||||
*
|
|
||||||
* Use {@link KeyValueDiffers} and {@link IterableDiffers} to add your custom check mechanisms.
|
|
||||||
*
|
*
|
||||||
* ### Example ([live demo](http://plnkr.co/edit/QpnIlF0CR2i5bcYbHEUJ?p=preview))
|
* ### Example ([live demo](http://plnkr.co/edit/QpnIlF0CR2i5bcYbHEUJ?p=preview))
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue