I need a data model class that can store identical information for two individuals simultaneously. For instance:
export class People {
constructor(
public person1Name: string = '',
public person1Age: number = 0,
public person1Game: string = '',
public person2Name: string = '',
public person2Age: number = 0,
public person2Game: string ='',
){}
}
This class holds the same details (name, age, game) for two people.
Although I could use a generic person model class, the issue is that I always receive precisely two sets of individual's information from an Angular service to the component.
With a generic person class, I would have to pass an array of objects like:
Array: [person1, person2]
In such a scenario, it would be challenging to handle in both the service and the component since I utilize the information differently.
More importantly, I transmit details of two individuals from the service through an observable.
Therefore, my question is, is it possible to create a model class that captures the same information for two individuals as illustrated above? as I prefer to avoid using an array of objects..
Thank you in advance.