docs: use SimpleChanges in component interaction guide (#39342)
Use the SimpleChanges interface in the example of component interaction guide PR Close #39342
This commit is contained in:
parent
90c0772743
commit
cf60e0e889
|
@ -1,6 +1,6 @@
|
||||||
/* tslint:disable:forin */
|
/* tslint:disable:forin */
|
||||||
// #docregion
|
// #docregion
|
||||||
import { Component, Input, OnChanges, SimpleChange } from '@angular/core';
|
import { Component, Input, OnChanges, SimpleChanges } from '@angular/core';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-version-child',
|
selector: 'app-version-child',
|
||||||
|
@ -17,7 +17,7 @@ export class VersionChildComponent implements OnChanges {
|
||||||
@Input() minor: number;
|
@Input() minor: number;
|
||||||
changeLog: string[] = [];
|
changeLog: string[] = [];
|
||||||
|
|
||||||
ngOnChanges(changes: {[propKey: string]: SimpleChange}) {
|
ngOnChanges(changes: SimpleChanges) {
|
||||||
const log: string[] = [];
|
const log: string[] = [];
|
||||||
for (const propName in changes) {
|
for (const propName in changes) {
|
||||||
const changedProp = changes[propName];
|
const changedProp = changes[propName];
|
||||||
|
|
|
@ -4,7 +4,7 @@ import { Component, ContentChildren, Directive, EventEmitter,
|
||||||
HostBinding, HostListener,
|
HostBinding, HostListener,
|
||||||
OnInit, OnChanges, OnDestroy,
|
OnInit, OnChanges, OnDestroy,
|
||||||
Pipe, PipeTransform,
|
Pipe, PipeTransform,
|
||||||
SimpleChange } from '@angular/core';
|
SimpleChanges } from '@angular/core';
|
||||||
|
|
||||||
import { of } from 'rxjs';
|
import { of } from 'rxjs';
|
||||||
import { delay } from 'rxjs/operators';
|
import { delay } from 'rxjs/operators';
|
||||||
|
@ -309,7 +309,7 @@ export class MyIfChildComponent implements OnInit, OnChanges, OnDestroy {
|
||||||
this.changeLog.push('ngOnDestroy called');
|
this.changeLog.push('ngOnDestroy called');
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnChanges(changes: {[propertyName: string]: SimpleChange}) {
|
ngOnChanges(changes: SimpleChanges) {
|
||||||
for (const propName in changes) {
|
for (const propName in changes) {
|
||||||
this.ngOnChangesCounter += 1;
|
this.ngOnChangesCounter += 1;
|
||||||
const prop = changes[propName];
|
const prop = changes[propName];
|
||||||
|
|
Loading…
Reference in New Issue