Update on numeric inputs
This commit is contained in:
@@ -146,4 +146,17 @@ export class EditBusinessListingComponent {
|
||||
changeListingCategory(value: 'business' | 'commercialProperty') {
|
||||
routeListingWithState(this.router, value, this.listing);
|
||||
}
|
||||
onNumericInputChange(value: string, modelProperty: string): void {
|
||||
const newValue = value === '' ? null : +value;
|
||||
this.setPropertyByPath(this, modelProperty, newValue);
|
||||
}
|
||||
|
||||
private setPropertyByPath(obj: any, path: string, value: any): void {
|
||||
const keys = path.split('.');
|
||||
let target = obj;
|
||||
for (let i = 0; i < keys.length - 1; i++) {
|
||||
target = target[keys[i]];
|
||||
}
|
||||
target[keys[keys.length - 1]] = value;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user