I want to list all the component properties (both private and public) in angular.
I have tried the following
ngOnInit() {
console.log(this.constructor.prototype);
}
But this is printing only the properties that have getter
methods defined. It is not printing the properties which do not have getters
or setters
. It also prints component methods
which I am not bothered.
Strange part is, it is not even displaying the public properties (which do not have getters).
Even I tried doing
console.log(this.constructor.prototype.hasOwnProperty('_queryState'));
But it returns me false
, which means it was not able to identify the property.
This question does not help me though.
How do I list all the properties?
If anyone is asking me why do I need to do this, it is for unit testing.