While creating a Model Driven Template Reactive forms, when I create model object from Form Value. Then model object is loosing its TYPE.
For a Simple Example:
This constructor will work with any type and will assign any matching filed.
export class Book {
public constructor(init?: Partial) {
Object.assign(this, init);
}
}
So you will be able to do this:
this.newBook = new Book(this.bookFormGroup.value);
This will safe you a lot of work if the Book class will have any change in future and became bigger.