public model = {
bool: false,
text: '',
array: [],
number: 0,
obj: {}
};
this.model.reset()
this.model = new Model()
class Model {
private _initialValues = {
name: 'name',
surname: 'surname'
}
constructor() { }
reset() {
Object.keys(this._initialValues).forEach(key => {
this[key] = this._initialValues[key];
})
}
}
class Model {
constructor() {
this.name = 'test'
}
reset() {
const newInstance = new Test();
Object.keys(newInstance).forEach(key => {
this[key] = newInstance[key];
})
}
}