After receiving a list of persons from the backend, it is automatically transformed into TypeScript business object class (Person) objects using Angular/rxjs.
export class Person {
Id: string;
Name: string;
Age: number;
}
The task at hand is to present these entities in a list with an extra column indicating whether records are selected or not - necessary for future processing.
The dilemma is - what would be the most appropriate approach to achieve this?
Should I create a PersonModel
class that extends Person
and includes an additional field for selection status?
export class PersonModel extends Person {
Selected: boolean;
}
Alternatively, should I overlook the fact that the back-end does not involve the Selected
property and simply add it to the existing Person
class?
export class Person {
Id: string;
Name: string;
Age: number;
Selected: boolean;
}
Are there alternative methods that are more suitable for addressing this scenario?