docs(lifecycle-hooks): `SimpleChange` -> `SimpleChanges` #2741 (#2742)

This commit is contained in:
Ward Bell 2016-11-02 21:50:38 -07:00 committed by GitHub
parent 35d8695752
commit ae35f0e017
3 changed files with 6 additions and 7 deletions

View File

@ -1,7 +1,7 @@
// #docregion // #docregion
import { import {
Component, Input, Component, Input,
OnChanges, SimpleChange, OnChanges, SimpleChanges,
} from '@angular/core'; } from '@angular/core';
import { LoggerService } from './logger.service'; import { LoggerService } from './logger.service';
@ -22,7 +22,7 @@ export class MyCounterComponent implements OnChanges {
@Input() counter: number; @Input() counter: number;
changeLog: string[] = []; changeLog: string[] = [];
ngOnChanges(changes: {[propertyName: string]: SimpleChange}) { ngOnChanges(changes: SimpleChanges) {
// Empty the changeLog whenever counter goes to zero // Empty the changeLog whenever counter goes to zero
// hint: this is a way to respond programmatically to external value changes. // hint: this is a way to respond programmatically to external value changes.
@ -36,7 +36,6 @@ export class MyCounterComponent implements OnChanges {
let prev = JSON.stringify(chng.previousValue); // first time is {}; after is integer let prev = JSON.stringify(chng.previousValue); // first time is {}; after is integer
this.changeLog.push(`counter: currentValue = ${cur}, previousValue = ${prev}`); this.changeLog.push(`counter: currentValue = ${cur}, previousValue = ${prev}`);
} }
} }
/***************************************/ /***************************************/

View File

@ -2,7 +2,7 @@
// #docregion // #docregion
import { import {
Component, Input, OnChanges, Component, Input, OnChanges,
SimpleChange, ViewChild SimpleChanges, ViewChild
} from '@angular/core'; } from '@angular/core';
class Hero { class Hero {
@ -33,7 +33,7 @@ export class OnChangesComponent implements OnChanges {
changeLog: string[] = []; changeLog: string[] = [];
// #docregion ng-on-changes // #docregion ng-on-changes
ngOnChanges(changes: {[propertyName: string]: SimpleChange}) { ngOnChanges(changes: SimpleChanges) {
for (let propName in changes) { for (let propName in changes) {
let chng = changes[propName]; let chng = changes[propName];
let cur = JSON.stringify(chng.currentValue); let cur = JSON.stringify(chng.currentValue);

View File

@ -7,7 +7,7 @@ import {
OnChanges, OnChanges,
OnDestroy, OnDestroy,
OnInit, OnInit,
SimpleChange SimpleChanges
} from '@angular/core'; } from '@angular/core';
import { Component, Input } from '@angular/core'; import { Component, Input } from '@angular/core';
import { LoggerService } from './logger.service'; import { LoggerService } from './logger.service';
@ -51,7 +51,7 @@ export class PeekABooComponent extends PeekABoo implements
} }
// only called for/if there is an @input variable set by parent. // only called for/if there is an @input variable set by parent.
ngOnChanges(changes: {[propertyName: string]: SimpleChange}) { ngOnChanges(changes: SimpleChanges) {
let changesMsgs: string[] = []; let changesMsgs: string[] = [];
for (let propName in changes) { for (let propName in changes) {
if (propName === 'name') { if (propName === 'name') {