parent
35d8695752
commit
ae35f0e017
|
@ -1,7 +1,7 @@
|
|||
// #docregion
|
||||
import {
|
||||
Component, Input,
|
||||
OnChanges, SimpleChange,
|
||||
OnChanges, SimpleChanges,
|
||||
} from '@angular/core';
|
||||
|
||||
import { LoggerService } from './logger.service';
|
||||
|
@ -22,7 +22,7 @@ export class MyCounterComponent implements OnChanges {
|
|||
@Input() counter: number;
|
||||
changeLog: string[] = [];
|
||||
|
||||
ngOnChanges(changes: {[propertyName: string]: SimpleChange}) {
|
||||
ngOnChanges(changes: SimpleChanges) {
|
||||
|
||||
// Empty the changeLog whenever counter goes to zero
|
||||
// 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
|
||||
this.changeLog.push(`counter: currentValue = ${cur}, previousValue = ${prev}`);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/***************************************/
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// #docregion
|
||||
import {
|
||||
Component, Input, OnChanges,
|
||||
SimpleChange, ViewChild
|
||||
SimpleChanges, ViewChild
|
||||
} from '@angular/core';
|
||||
|
||||
class Hero {
|
||||
|
@ -33,7 +33,7 @@ export class OnChangesComponent implements OnChanges {
|
|||
changeLog: string[] = [];
|
||||
|
||||
// #docregion ng-on-changes
|
||||
ngOnChanges(changes: {[propertyName: string]: SimpleChange}) {
|
||||
ngOnChanges(changes: SimpleChanges) {
|
||||
for (let propName in changes) {
|
||||
let chng = changes[propName];
|
||||
let cur = JSON.stringify(chng.currentValue);
|
||||
|
|
|
@ -7,7 +7,7 @@ import {
|
|||
OnChanges,
|
||||
OnDestroy,
|
||||
OnInit,
|
||||
SimpleChange
|
||||
SimpleChanges
|
||||
} from '@angular/core';
|
||||
import { Component, Input } from '@angular/core';
|
||||
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.
|
||||
ngOnChanges(changes: {[propertyName: string]: SimpleChange}) {
|
||||
ngOnChanges(changes: SimpleChanges) {
|
||||
let changesMsgs: string[] = [];
|
||||
for (let propName in changes) {
|
||||
if (propName === 'name') {
|
||||
|
|
Loading…
Reference in New Issue