Skip to content

Instantly share code, notes, and snippets.

Created January 6, 2018 17:44
Show Gist options
  • Select an option

  • Save anonymous/b67938bb2b5cb5861e1b331b36893e51 to your computer and use it in GitHub Desktop.

Select an option

Save anonymous/b67938bb2b5cb5861e1b331b36893e51 to your computer and use it in GitHub Desktop.
import { Component, Input, OnChanges, SimpleChanges, SimpleChange } from '@angular/core';
declare class TypedChange<T = any> extends SimpleChange {
previousValue: T;
currentValue: T;
firstChange: boolean;
constructor(previousValue: T, currentValue: T, firstChange: boolean);
/**
* Check whether the new value is the first value assigned.
*/
isFirstChange(): boolean;
}
interface MyChanges extends SimpleChanges {
status: TypedChange<string>
}
@Component({
selector: 'my-app',
templateUrl: './app.component.html',
styleUrls: [ './app.component.css' ]
})
export class AppComponent implements OnChanges {
@Input() status: string;
name = 'Angular 5';
ngOnChanges( changes: MyChanges ) {
if( changes.status ) {
console.log(changes.status.currentValue.substr(0));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment