I am seeking a way to retrieve all the component properties, including private and public ones, in Angular.
My attempts so far include:
ngOnInit() {
console.log(this.constructor.prototype);
}
However, this code only displays properties with defined getter
methods. It does not show properties without getters or setters. Additionally, it also lists component methods
, which I am not interested in.
Interestingly, it does not even show public properties (those without getters).
I have also tried:
console.log(this.constructor.prototype.hasOwnProperty('_queryState'));
But it simply returns false
, indicating that it did not recognize the property.
This question on Stack Overflow did not provide a solution either.
So, my main question remains: How can I effectively list all properties?
In case anyone wonders why I need this information, it is for the purpose of unit testing.