Angular 2 - Get all @input() in directives or component

2.1k Views Asked by At

Is there a way to get all component or directive property with @Input decorators in angular 2?

1

There are 1 best solutions below

0
On BEST ANSWER

If you want to get all inputs value you can go with ngOnChanges hook.

class MyComponent implements OnChanges {
  @Input() myProp: any;
  ngOnChanges(changes: SimpleChanges) {
    console.log('ngOnChanges - myProp = ' + changes['myProp'].currentValue);
  }
}