Check if the 'rowData' property exists and assign a value. Can we approach it like this?
if(this.tableObj.hasOwnProperty('rowData')) {
this.tableObj.rowData = this.defVal.rowData;
}
I encountered an error when attempting this, specifically inside the if statement.
Property 'rowData' does not exist on type '{}'.
UPDATE:
@Input() tableObj: {};
defVal: {
rowData: [1,2,3]
};
ngOnInit() {
}
reset() {
if( this.tableObj.rowData !== undefined) {
this.tableObj.rowData = this.defVal.rowData;
}
}
Error message while building:
error TS2339: Property 'rowData' does not exist on type 'never'.