Created
January 6, 2018 17:44
-
-
Save anonymous/b67938bb2b5cb5861e1b331b36893e51 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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