AliShahbaz

Detect change of a property

Apr 26th, 2021
880
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // this won't work with setting attribute of the component in Parent component
  2. // need to set property value via Component
  3. // i.e., this.confirmDialog.opened = true
  4. private _opened: boolean;
  5. get opened(): boolean { return this._opened; }
  6. @Input('opened') set opened(val: boolean) { // to detect changes, needed to add set method
  7.     this._opened = val;
  8.     this.openDialog();
  9. }
RAW Paste Data