I've the following class:
export class Test {
private _rowsCount: string;
public get RowsCount(): string {
return this._rowsCount;
};
public set RowsCount(value: string) {
this._rowsCount = value;
};
private _rowsCount2: string;
public get RowsCount2(): string {
return this._rowsCount2;
};
public set RowsCount2(value: string) {
this._rowsCount2 = value;
};
}
I need to iterate over the properties in a specific class, I tried the following:
Object.keys(this).forEach((key)=> {
console.log(key);
});
But the problem that this iterate just over the private
fields, I tried also the following I got all the methods
and properties
:
for (var property in this) {
if (this.hasOwnProperty(property)) {
console.log(property);
}
}
Does anyone have a solution?
Thanks!