Skip to content

Instantly share code, notes, and snippets.

@YonathanMeguira
Last active March 14, 2018 13:03
Show Gist options
  • Save YonathanMeguira/e4d505d55805b18e273789cbf93ae337 to your computer and use it in GitHub Desktop.
Save YonathanMeguira/e4d505d55805b18e273789cbf93ae337 to your computer and use it in GitHub Desktop.
watch changes in input decorators
// set up some class with an input decorator (the one we want to watch and act upon change
export class MyComponent {
myBooleanValue: boolean;
@Input()
set myBooleanValue(newValue: boolean) {
// will display this message as soon as the value of 'myBooleanValue' changes
console.log(`old value was ${this.booleanValue}, new value is ${newValue}`;
this.myBooleanValue = newValue;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment